<!DOCTYPE html>
<!-- saved from url=(0080)https://juejin.im/book/5bdc715fe51d454e755f75ef/section/5bed40d951882545f73004f6 -->
<html lang="zh-CN"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"><meta name="viewport" content="width=device-width,initial-scale=1,user-scalable=no,viewport-fit=cover"><meta name="google-site-verification" content="cCHsgG9ktuCTgWgYfqCJql8AeR4gAne4DTZqztPoirE"><meta name="apple-itunes-app" content="app-id=987739104"><meta name="baidu-site-verification" content="qiK2a1kcFc"><meta name="360-site-verification" content="4c3c7d57d59f0e1a308462fbc7fd7e51"><meta name="sogou_site_verification" content="c49WUDZczQ"><style>body {
        font-size: 16px;
        line-height: 2;
      }
      a, button, input {
        margin: 1rem 1.5rem;
      }
      img {
        width: 0;
        height: 0;
      }
      #juejin {
        overflow-x: hidden;
      }</style><title data-vue-meta="true">前端面试之道 - yck - 掘金小册</title><link rel="apple-touch-icon" sizes="180x180" href="https://b-gold-cdn.xitu.io/favicons/v2/apple-touch-icon.png"><link rel="icon" type="image/png" sizes="32x32" href="https://b-gold-cdn.xitu.io/favicons/v2/favicon-32x32.png"><link rel="icon" type="image/png" sizes="16x16" href="https://b-gold-cdn.xitu.io/favicons/v2/favicon-16x16.png"><link rel="manifest" href="https://b-gold-cdn.xitu.io/favicons/v2/manifest.json"><link rel="mask-icon" href="https://b-gold-cdn.xitu.io/favicons/v2/safari-pinned-tab.svg" color="#5bbad5"><link rel="shortcut icon" href="https://b-gold-cdn.xitu.io/favicons/v2/favicon.ico"><meta name="msapplication-config" content="https://b-gold-cdn.xitu.io/favicons/v2/browserconfig.xml"><meta name="theme-color" content="#ffffff"><link rel="search" title="掘金" href="https://b-gold-cdn.xitu.io/conf/search.xml" type="application/opensearchdescription+xml"><link rel="stylesheet" href="./3.JS 基础知识点及常考面试题（二）_files/ionicons.min.css"><link rel="stylesheet" href="./3.JS 基础知识点及常考面试题（二）_files/iconfont.css"><link href="./3.JS 基础知识点及常考面试题（二）_files/0.f53dd8c7dec37187a1f0.css" rel="stylesheet"><script async="" src="./3.JS 基础知识点及常考面试题（二）_files/hm.js"></script><script async="" src="./3.JS 基础知识点及常考面试题（二）_files/analytics.js"></script><script type="text/javascript" async="" src="./3.JS 基础知识点及常考面试题（二）_files/vds.js"></script><script charset="utf-8" src="./3.JS 基础知识点及常考面试题（二）_files/13.be327205e46595a11182.js"></script><meta data-vmid="keywords" name="keywords" content="掘金,稀土,Vue.js,微信小程序,Kotlin,RxJava,React Native,Wireshark,敏捷开发,Bootstrap,OKHttp,正则表达式,WebGL,Webpack,Docker,MVVM" data-vue-meta="true"><meta data-vmid="description" name="description" content="掘金是一个帮助开发者成长的社区，是给开发者用的 Hacker News，给设计师用的 Designer News，和给产品经理用的 Medium。掘金的技术文章由稀土上聚集的技术大牛和极客共同编辑为你筛选出最优质的干货，其中包括：Android、iOS、前端、后端等方面的内容。用户每天都可以在这里找到技术世界的头条内容。与此同时，掘金内还有沸点、掘金翻译计划、线下活动、专栏文章等内容。即使你是 GitHub、StackOverflow、开源中国的用户，我们相信你也可以在这里有所收获。" data-vue-meta="true"></head><body><div id="juejin" data-v-c5c2a81e=""><div class="global-component-box" data-v-c5c2a81e=""><!----><div data-v-c8da6528="" data-v-c5c2a81e="" class="alert-list alert-list"></div><!----><!----><!----><div class="emoji-barrage" data-v-beb06b1a="" data-v-c5c2a81e=""><!----></div><div class="book-new-user-award-popup" style="display:none;" data-v-40eb6fce="" data-v-c5c2a81e=""><div class="content-box" style="display:;" data-v-40eb6fce=""><div class="close ion-close-round" data-v-40eb6fce=""></div><div class="header" data-v-40eb6fce=""><div class="icon" data-v-40eb6fce=""><img src="./3.JS 基础知识点及常考面试题（二）_files/icon.a87e5ae.svg" data-v-40eb6fce=""></div><div class="txt" data-v-40eb6fce="">新人专享好礼</div></div><div class="desc" data-v-40eb6fce="">凡未购买过小册的用户，均可领取三张 5 折新人专享券，购买小册时自动使用专享券，最高可节省 45 元。</div><div class="tickets" data-v-40eb6fce=""><div class="ticket" data-v-40eb6fce=""><div class="ticket__inner" data-v-40eb6fce=""><div class="enjoy" data-v-40eb6fce=""><span class="new-title" data-v-40eb6fce="">小册新人 5 折券</span></div><div class="sale" data-v-40eb6fce="">最高可省 15 元</div></div></div><div class="ticket" data-v-40eb6fce=""><div class="ticket__inner" data-v-40eb6fce=""><div class="enjoy" data-v-40eb6fce=""><span class="new-title" data-v-40eb6fce="">小册新人 5 折券</span></div><div class="sale" data-v-40eb6fce="">最高可省 15 元</div></div></div><div class="ticket" data-v-40eb6fce=""><div class="ticket__inner" data-v-40eb6fce=""><div class="enjoy" data-v-40eb6fce=""><span class="new-title" data-v-40eb6fce="">小册新人 5 折券</span></div><div class="sale" data-v-40eb6fce="">最高可省 15 元</div></div></div></div><div class="remark" data-v-40eb6fce="">注：专享券的使用期限在领券的七天内。</div><div class="submit-btn" data-v-40eb6fce="">一键领取</div></div><div class="model success" style="display:none;" data-v-40eb6fce=""><div class="heading" data-v-40eb6fce="">领取成功</div><div class="content-text" data-v-40eb6fce="">购买小册时自动使用专享券</div><div class="btn-success-footer" data-v-40eb6fce=""><div class="btn-ok" data-v-40eb6fce="">知道了</div><div class="btn-ok btn-link" data-v-40eb6fce="">前往小册首页</div></div></div><div class="model fail" style="display:none;" data-v-40eb6fce=""><div class="heading" data-v-40eb6fce="">领取失败</div><div class="content-text" data-v-40eb6fce="">本活动仅适用于小册新用户</div><div class="btn-ok" data-v-40eb6fce="">知道了</div></div></div><!----></div><!----><div data-v-25b273c2="" data-v-c5c2a81e="" class="book-read-view"><section data-v-25b273c2="" class="book-section"><div data-v-25b273c2="" class="book-summary"><div data-v-25b273c2="" class="book-summary-masker"></div><div data-v-25b273c2="" class="book-summary-inner"><div data-v-25b273c2="" class="book-summary__header"><a data-v-25b273c2="" href="https://juejin.im/books" target="" rel="" class="logo"><img data-v-25b273c2="" src="./3.JS 基础知识点及常考面试题（二）_files/logo.a7995ad.svg"></a><div data-v-25b273c2="" class="label">小册</div><!----></div><!----><div data-v-d0eb2184="" data-v-25b273c2="" class="book-directory book-directory bought"><a data-v-d0eb2184="" class="section section-link read"><div data-v-d0eb2184="" class="step"><div data-v-d0eb2184="" class="step-btn">1</div></div><div data-v-d0eb2184="" class="center"><div data-v-d0eb2184="" class="title">小册食用指南</div><!----><!----></div><!----></a><a data-v-d0eb2184="" class="section section-link read"><div data-v-d0eb2184="" class="step"><div data-v-d0eb2184="" class="step-btn">2</div></div><div data-v-d0eb2184="" class="center"><div data-v-d0eb2184="" class="title">JS 基础知识点及常考面试题（一）</div><!----><!----></div><!----></a><a data-v-d0eb2184="" class="section route-active section-link"><div data-v-d0eb2184="" class="step"><div data-v-d0eb2184="" class="step-btn">3</div></div><div data-v-d0eb2184="" class="center"><div data-v-d0eb2184="" class="title">JS 基础知识点及常考面试题（二）</div><!----><!----></div><!----></a><a data-v-d0eb2184="" class="section section-link"><div data-v-d0eb2184="" class="step"><div data-v-d0eb2184="" class="step-btn">4</div></div><div data-v-d0eb2184="" class="center"><div data-v-d0eb2184="" class="title">ES6 知识点及常考面试题</div><!----><!----></div><!----></a><a data-v-d0eb2184="" class="section section-link"><div data-v-d0eb2184="" class="step"><div data-v-d0eb2184="" class="step-btn">5</div></div><div data-v-d0eb2184="" class="center"><div data-v-d0eb2184="" class="title">JS 异步编程及常考面试题</div><!----><!----></div><!----></a><a data-v-d0eb2184="" class="section section-link"><div data-v-d0eb2184="" class="step"><div data-v-d0eb2184="" class="step-btn">6</div></div><div data-v-d0eb2184="" class="center"><div data-v-d0eb2184="" class="title">手写 Promise</div><!----><!----></div><!----></a><a data-v-d0eb2184="" class="section section-link"><div data-v-d0eb2184="" class="step"><div data-v-d0eb2184="" class="step-btn">7</div></div><div data-v-d0eb2184="" class="center"><div data-v-d0eb2184="" class="title">Event Loop</div><!----><!----></div><!----></a><a data-v-d0eb2184="" class="section section-link"><div data-v-d0eb2184="" class="step"><div data-v-d0eb2184="" class="step-btn">8</div></div><div data-v-d0eb2184="" class="center"><div data-v-d0eb2184="" class="title">JS 进阶知识点及常考面试题</div><!----><!----></div><!----></a><a data-v-d0eb2184="" class="section section-link"><div data-v-d0eb2184="" class="step"><div data-v-d0eb2184="" class="step-btn">9</div></div><div data-v-d0eb2184="" class="center"><div data-v-d0eb2184="" class="title">JS 思考题</div><!----><!----></div><!----></a><a data-v-d0eb2184="" class="section section-link"><div data-v-d0eb2184="" class="step"><div data-v-d0eb2184="" class="step-btn">10</div></div><div data-v-d0eb2184="" class="center"><div data-v-d0eb2184="" class="title">DevTools Tips</div><!----><!----></div><!----></a><a data-v-d0eb2184="" class="section section-link"><div data-v-d0eb2184="" class="step"><div data-v-d0eb2184="" class="step-btn">11</div></div><div data-v-d0eb2184="" class="center"><div data-v-d0eb2184="" class="title">浏览器基础知识点及常考面试题</div><!----><!----></div><!----></a><a data-v-d0eb2184="" class="section section-link"><div data-v-d0eb2184="" class="step"><div data-v-d0eb2184="" class="step-btn">12</div></div><div data-v-d0eb2184="" class="center"><div data-v-d0eb2184="" class="title">浏览器缓存机制</div><!----><!----></div><!----></a><a data-v-d0eb2184="" class="section section-link"><div data-v-d0eb2184="" class="step"><div data-v-d0eb2184="" class="step-btn">13</div></div><div data-v-d0eb2184="" class="center"><div data-v-d0eb2184="" class="title">浏览器渲染原理</div><!----><!----></div><!----></a><a data-v-d0eb2184="" class="section section-link"><div data-v-d0eb2184="" class="step"><div data-v-d0eb2184="" class="step-btn">14</div></div><div data-v-d0eb2184="" class="center"><div data-v-d0eb2184="" class="title">安全防范知识点</div><!----><!----></div><!----></a><a data-v-d0eb2184="" class="section section-link"><div data-v-d0eb2184="" class="step"><div data-v-d0eb2184="" class="step-btn">15</div></div><div data-v-d0eb2184="" class="center"><div data-v-d0eb2184="" class="title">从 V8 中看 JS 性能优化</div><!----><!----></div><!----></a><a data-v-d0eb2184="" class="section section-link"><div data-v-d0eb2184="" class="step"><div data-v-d0eb2184="" class="step-btn">16</div></div><div data-v-d0eb2184="" class="center"><div data-v-d0eb2184="" class="title">性能优化琐碎事</div><!----><!----></div><!----></a><a data-v-d0eb2184="" class="section section-link"><div data-v-d0eb2184="" class="step"><div data-v-d0eb2184="" class="step-btn">17</div></div><div data-v-d0eb2184="" class="center"><div data-v-d0eb2184="" class="title">Webpack 性能优化</div><!----><!----></div><!----></a><a data-v-d0eb2184="" class="section section-link"><div data-v-d0eb2184="" class="step"><div data-v-d0eb2184="" class="step-btn">18</div></div><div data-v-d0eb2184="" class="center"><div data-v-d0eb2184="" class="title">实现小型打包工具</div><!----><!----></div><!----></a><a data-v-d0eb2184="" class="section section-link"><div data-v-d0eb2184="" class="step"><div data-v-d0eb2184="" class="step-btn">19</div></div><div data-v-d0eb2184="" class="center"><div data-v-d0eb2184="" class="title">React 和 Vue 两大框架之间的相爱相杀</div><!----><!----></div><!----></a><a data-v-d0eb2184="" class="section section-link"><div data-v-d0eb2184="" class="step"><div data-v-d0eb2184="" class="step-btn">20</div></div><div data-v-d0eb2184="" class="center"><div data-v-d0eb2184="" class="title">Vue 常考基础知识点</div><!----><!----></div><!----></a><a data-v-d0eb2184="" class="section section-link"><div data-v-d0eb2184="" class="step"><div data-v-d0eb2184="" class="step-btn">21</div></div><div data-v-d0eb2184="" class="center"><div data-v-d0eb2184="" class="title">Vue 常考进阶知识点</div><!----><!----></div><!----></a><a data-v-d0eb2184="" class="section section-link"><div data-v-d0eb2184="" class="step"><div data-v-d0eb2184="" class="step-btn">22</div></div><div data-v-d0eb2184="" class="center"><div data-v-d0eb2184="" class="title">React 常用知识点</div><!----><div data-v-d0eb2184="" class="sub-line"><div data-v-d0eb2184="" class="writing">写作中...</div></div></div><!----></a><a data-v-d0eb2184="" class="section section-link"><div data-v-d0eb2184="" class="step"><div data-v-d0eb2184="" class="step-btn">23</div></div><div data-v-d0eb2184="" class="center"><div data-v-d0eb2184="" class="title">React 进阶</div><!----><div data-v-d0eb2184="" class="sub-line"><div data-v-d0eb2184="" class="writing">写作中...</div></div></div><!----></a><a data-v-d0eb2184="" class="section section-link"><div data-v-d0eb2184="" class="step"><div data-v-d0eb2184="" class="step-btn">24</div></div><div data-v-d0eb2184="" class="center"><div data-v-d0eb2184="" class="title">监控</div><!----><div data-v-d0eb2184="" class="sub-line"><div data-v-d0eb2184="" class="writing">写作中...</div></div></div><!----></a><a data-v-d0eb2184="" class="section section-link"><div data-v-d0eb2184="" class="step"><div data-v-d0eb2184="" class="step-btn">25</div></div><div data-v-d0eb2184="" class="center"><div data-v-d0eb2184="" class="title">TCP / UDP</div><!----><div data-v-d0eb2184="" class="sub-line"><div data-v-d0eb2184="" class="writing">写作中...</div></div></div><!----></a><a data-v-d0eb2184="" class="section section-link"><div data-v-d0eb2184="" class="step"><div data-v-d0eb2184="" class="step-btn">26</div></div><div data-v-d0eb2184="" class="center"><div data-v-d0eb2184="" class="title">HTTP 及 TLS</div><!----><div data-v-d0eb2184="" class="sub-line"><div data-v-d0eb2184="" class="writing">写作中...</div></div></div><!----></a><a data-v-d0eb2184="" class="section section-link"><div data-v-d0eb2184="" class="step"><div data-v-d0eb2184="" class="step-btn">27</div></div><div data-v-d0eb2184="" class="center"><div data-v-d0eb2184="" class="title">HTTP 2.0</div><!----><div data-v-d0eb2184="" class="sub-line"><div data-v-d0eb2184="" class="writing">写作中...</div></div></div><!----></a><a data-v-d0eb2184="" class="section section-link"><div data-v-d0eb2184="" class="step"><div data-v-d0eb2184="" class="step-btn">28</div></div><div data-v-d0eb2184="" class="center"><div data-v-d0eb2184="" class="title">输入 URL 到页面渲染的整个流程</div><!----><div data-v-d0eb2184="" class="sub-line"><div data-v-d0eb2184="" class="writing">写作中...</div></div></div><!----></a><a data-v-d0eb2184="" class="section section-link"><div data-v-d0eb2184="" class="step"><div data-v-d0eb2184="" class="step-btn">29</div></div><div data-v-d0eb2184="" class="center"><div data-v-d0eb2184="" class="title">设计模式</div><!----><div data-v-d0eb2184="" class="sub-line"><div data-v-d0eb2184="" class="writing">写作中...</div></div></div><!----></a><a data-v-d0eb2184="" class="section section-link"><div data-v-d0eb2184="" class="step"><div data-v-d0eb2184="" class="step-btn">30</div></div><div data-v-d0eb2184="" class="center"><div data-v-d0eb2184="" class="title">常见数据结构</div><!----><div data-v-d0eb2184="" class="sub-line"><div data-v-d0eb2184="" class="writing">写作中...</div></div></div><!----></a><a data-v-d0eb2184="" class="section section-link"><div data-v-d0eb2184="" class="step"><div data-v-d0eb2184="" class="step-btn">31</div></div><div data-v-d0eb2184="" class="center"><div data-v-d0eb2184="" class="title">常考算法题解析</div><!----><div data-v-d0eb2184="" class="sub-line"><div data-v-d0eb2184="" class="writing">写作中...</div></div></div><!----></a><a data-v-d0eb2184="" class="section section-link"><div data-v-d0eb2184="" class="step"><div data-v-d0eb2184="" class="step-btn">32</div></div><div data-v-d0eb2184="" class="center"><div data-v-d0eb2184="" class="title">CSS 常考面试题解析</div><!----><div data-v-d0eb2184="" class="sub-line"><div data-v-d0eb2184="" class="writing">写作中...</div></div></div><!----></a><a data-v-d0eb2184="" class="section section-link"><div data-v-d0eb2184="" class="step"><div data-v-d0eb2184="" class="step-btn">33</div></div><div data-v-d0eb2184="" class="center"><div data-v-d0eb2184="" class="title">如何写好一封简历</div><!----><!----></div><!----></a><a data-v-d0eb2184="" class="section section-link"><div data-v-d0eb2184="" class="step"><div data-v-d0eb2184="" class="step-btn">34</div></div><div data-v-d0eb2184="" class="center"><div data-v-d0eb2184="" class="title">面试常用技巧</div><!----><!----></div><!----></a><a data-v-d0eb2184="" class="section section-link"><div data-v-d0eb2184="" class="step"><div data-v-d0eb2184="" class="step-btn">35</div></div><div data-v-d0eb2184="" class="center"><div data-v-d0eb2184="" class="title">前方的路，让我们结伴同行</div><!----><!----></div><!----></a></div><div data-v-25b273c2="" class="book-summary__footer"><div data-v-25b273c2="" class="qr-icon"><img data-v-25b273c2="" src="./3.JS 基础知识点及常考面试题（二）_files/qr-icon.881015a.svg"></div><div data-v-25b273c2="" class="qr-tips"><span data-v-25b273c2="" class="ion-close"></span><div data-v-25b273c2="" class="title"><span data-v-25b273c2="">关注公众号</span><span data-v-25b273c2="">领取优惠码</span></div><div data-v-25b273c2="" class="qr-img"><img data-v-25b273c2="" src="./3.JS 基础知识点及常考面试题（二）_files/wx-qr.13d8b4d.png"></div></div></div></div></div><div data-v-25b273c2="" class="book-content"><div data-v-25b273c2="" class="book-content-inner"><div data-v-25b273c2="" class="book-content__header visible"><div data-v-25b273c2="" class="switch"><img data-v-25b273c2="" src="./3.JS 基础知识点及常考面试题（二）_files/icon.3e69d5a.svg"></div><div data-v-25b273c2="" class="menu"><img data-v-25b273c2="" src="./3.JS 基础知识点及常考面试题（二）_files/menu.74b9add.svg"></div><div data-v-25b273c2="" class="title"><a data-v-25b273c2="" href="https://juejin.im/book/5bdc715fe51d454e755f75ef" target="" rel="">前端面试之道</a></div><div data-v-e1714a36="" data-v-25b273c2="" class="user-auth user-auth"><div data-v-e1714a36="" class="nav-item menu"><div data-v-57c47624="" data-v-cf310dfc="" data-v-e1714a36="" data-src="https://avatars0.githubusercontent.com/u/33979626?v=4" class="lazy avatar avatar loaded" style="background-image: url(&quot;https://avatars0.githubusercontent.com/u/33979626?v=4&quot;);"></div><div data-v-e1714a36="" class="nav-menu user-dropdown-list" style="display: none;"><ul data-v-e1714a36="" class="nav-menu-item-group"><li data-v-e1714a36="" class="nav-menu-item"><a data-v-e1714a36=""><i data-v-e1714a36="" class="fengwei fw-write"></i><span data-v-e1714a36="">写文章</span></a></li><!----><li data-v-e1714a36="" class="nav-menu-item"><a data-v-e1714a36=""><i data-v-e1714a36="" class="fengwei fw-draft"></i><span data-v-e1714a36="">草稿</span></a></li></ul><ul data-v-e1714a36="" class="nav-menu-item-group"><li data-v-e1714a36="" class="nav-menu-item"><a data-v-e1714a36="" href="https://juejin.im/user/5aa105a7518825555f0c8a90"><i data-v-e1714a36="" class="fengwei fw-person"></i><span data-v-e1714a36="">我的主页</span></a></li><li data-v-e1714a36="" class="nav-menu-item"><a data-v-e1714a36="" href="https://juejin.im/user/5aa105a7518825555f0c8a90/likes"><i data-v-e1714a36="" class="fengwei fw-like"></i><span data-v-e1714a36="">我喜欢的</span></a></li><!----><li data-v-e1714a36="" class="nav-menu-item"><a data-v-e1714a36="" href="https://juejin.im/user/5aa105a7518825555f0c8a90/collections"><i data-v-e1714a36="" class="fengwei fw-collection"></i><span data-v-e1714a36="">我的收藏集</span></a></li><li data-v-e1714a36="" class="nav-menu-item"><a data-v-e1714a36="" href="https://juejin.im/user/5aa105a7518825555f0c8a90/books?type=bought"><i data-v-e1714a36="" class="fengwei fw-bought"></i><span data-v-e1714a36="">已购</span></a></li><!----><li data-v-e1714a36="" class="nav-menu-item"><a data-v-e1714a36="" href="https://juejin.im/subscribe"><i data-v-e1714a36="" class="fengwei fw-tag"></i><span data-v-e1714a36="">标签管理</span></a></li></ul><ul data-v-e1714a36="" class="nav-menu-item-group"><li data-v-e1714a36="" class="nav-menu-item"><a data-v-e1714a36="" href="https://juejin.im/user/settings"><i data-v-e1714a36="" class="fengwei fw-setting"></i><span data-v-e1714a36="">设置</span></a></li><li data-v-e1714a36="" class="nav-menu-item more"><a data-v-e1714a36=""><i data-v-e1714a36="" class="fengwei fw-info"></i><span data-v-e1714a36="">关于</span><i data-v-e1714a36="" class="ion-chevron-right more-icon"></i></a><div data-v-e1714a36="" class="nav-menu more-dropdown-list"><ul data-v-e1714a36="" class="nav-menu-item-group"><li data-v-e1714a36="" class="nav-menu-item"><a data-v-e1714a36="" href="https://juejin.im/app" target="_blank">下载应用</a></li><li data-v-e1714a36="" class="nav-menu-item"><a data-v-e1714a36="" href="https://juejin.im/about" target="_blank">关于</a></li><li data-v-e1714a36="" class="nav-menu-item"><a data-v-e1714a36="" href="https://xitu.io/jobs" target="_blank">加入我们</a></li><li data-v-e1714a36="" class="nav-menu-item"><a data-v-e1714a36="" href="https://github.com/xitu/gold-miner" rel="nofollow noopener noreferrer" target="_blank">翻译计划</a></li><li data-v-e1714a36="" class="nav-menu-item"><a data-v-e1714a36="" href="https://bd.juejin.im/?utm_campaign=bd&amp;utm_source=web&amp;utm_medium=nav" target="_blank">合作伙伴</a></li></ul></div></li></ul><ul data-v-e1714a36="" class="nav-menu-item-group"><li data-v-e1714a36="" class="nav-menu-item"><a data-v-e1714a36=""><i data-v-e1714a36="" class="fengwei fw-logout"></i><span data-v-e1714a36="">登出</span></a></li></ul></div></div><!----></div><!----></div><div data-v-25b273c2="" class="book-body transition--next"><div data-v-b0f6a942="" data-v-25b273c2="" class="section-view book-section-content"><div data-v-ecce5e7e="" data-v-b0f6a942="" class="section-content"><div data-v-ecce5e7e="" class="section-page book-section-view"><div data-v-ecce5e7e="" class="entry-content article-content"><h1 class="heading" data-id="heading-0">JS 基础知识点及常考面试题（二）</h1>
<p>在这一章节中我们继续来了解 JS 的一些常考和容易混乱的基础知识点。</p>
<h2 class="heading" data-id="heading-1">== vs ===</h2>
<blockquote class="warning"><p>涉及面试题：== 和 === 有什么区别？
</p></blockquote><p>对于 <code>==</code> 来说，如果对比双方的类型<strong>不一样</strong>的话，就会进行<strong>类型转换</strong>，这也就用到了我们上一章节讲的内容。</p>
<p>假如我们需要对比 <code>x</code> 和 <code>y</code> 是否相同，就会进行如下判断流程：</p>
<ol>
<li>首先会判断两者类型是否<strong>相同</strong>。相同的话就是比大小了</li>
<li>类型不相同的话，那么就会进行类型转换</li>
<li>会先判断是否在对比 <code>null</code> 和 <code>undefined</code>，是的话就会返回 <code>true</code></li>
<li>判断两者类型是否为 <code>string</code> 和 <code>number</code>，是的话就会将字符串转换为 <code>number</code><pre><code class="hljs js" lang="js"><span class="hljs-number">1</span> == <span class="hljs-string">'1'</span>
      ↓
<span class="hljs-number">1</span> ==  <span class="hljs-number">1</span>
</code></pre></li>
<li>判断其中一方是否为 <code>boolean</code>，是的话就会把 <code>boolean</code> 转为 <code>number</code> 再进行判断<pre><code class="hljs js" lang="js"><span class="hljs-string">'1'</span> == <span class="hljs-literal">true</span>
        ↓
<span class="hljs-string">'1'</span> ==  <span class="hljs-number">1</span>
        ↓
 <span class="hljs-number">1</span>  ==  <span class="hljs-number">1</span>
</code></pre></li>
<li>判断其中一方是否为 <code>object</code> 且另一方为 <code>string</code>、<code>number</code> 或者 <code>symbol</code>，是的话就会把 <code>object</code> 转为原始类型再进行判断<pre><code class="hljs js" lang="js"><span class="hljs-string">'1'</span> == { <span class="hljs-attr">name</span>: <span class="hljs-string">'yck'</span> }
        ↓
<span class="hljs-string">'1'</span> == <span class="hljs-string">'[object Object]'</span>
</code></pre></li>
</ol>
<blockquote class="warning"><p>思考题：看完了上面的步骤，对于 [] == ![] 你是否能正确写出答案呢？
</p></blockquote><p>如果你觉得记忆步骤太麻烦的话，我还提供了流程图供大家使用：</p>
<p></p><figure><img class="lazyload inited" data-src="https://user-gold-cdn.xitu.io/2018/12/19/167c4a2627fe55f1?imageView2/0/w/1280/h/960/format/webp/ignore-error/1" data-width="1005" data-height="426" src="data:image/svg+xml;utf8,&lt;?xml version=&quot;1.0&quot;?&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; version=&quot;1.1&quot; width=&quot;1005&quot; height=&quot;426&quot;&gt;&lt;/svg&gt;"><figcaption></figcaption></figure><p></p>
<p>当然了，这个流程图并没有将所有的情况都列举出来，我这里只将常用到的情况列举了，如果你想了解更多的内容可以参考 <a target="_blank" href="https://link.juejin.im/?target=https%3A%2F%2Fwww.ecma-international.org%2Fecma-262%2F5.1%2F%23sec-11.9.1" rel="nofollow noopener noreferrer">标准文档</a>。</p>
<p>对于 <code>===</code> 来说就简单多了，就是判断两者类型和值是否相同。</p>
<h2 class="heading" data-id="heading-2">闭包</h2>
<blockquote class="warning"><p>涉及面试题：什么是闭包？
</p></blockquote><p>闭包的定义其实很简单：函数 A 内部有一个函数 B，函数 B 可以访问到函数 A 中的变量，那么函数 B 就是闭包。</p>
<pre><code class="hljs js" lang="js"><span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">A</span>(<span class="hljs-params"></span>) </span>{
  <span class="hljs-keyword">let</span> a = <span class="hljs-number">1</span>
  <span class="hljs-built_in">window</span>.B = <span class="hljs-function"><span class="hljs-keyword">function</span> (<span class="hljs-params"></span>) </span>{
      <span class="hljs-built_in">console</span>.log(a)
  }
}
A()
B() <span class="hljs-comment">// 1</span>
</code></pre><p>很多人对于闭包的解释可能是函数嵌套了函数，然后返回一个函数。其实这个解释是不完整的，就比如我上面这个例子就可以反驳这个观点。</p>
<p>在 JS 中，闭包存在的意义就是让我们可以间接访问函数内部的变量。</p>
<blockquote class="warning"><p>经典面试题，循环中使用闭包解决 `var` 定义函数的问题
</p></blockquote><pre><code class="hljs Js" lang="Js"><span class="hljs-keyword">for</span> (<span class="hljs-keyword">var</span> i = <span class="hljs-number">1</span>; i &lt;= <span class="hljs-number">5</span>; i++) {
  setTimeout(<span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">timer</span>(<span class="hljs-params"></span>) </span>{
    <span class="hljs-built_in">console</span>.log(i)
  }, i * <span class="hljs-number">1000</span>)
}
</code></pre><p>首先因为 <code>setTimeout</code> 是个异步函数，所以会先把循环全部执行完毕，这时候 <code>i</code> 就是 6 了，所以会输出一堆 6。</p>
<p>解决办法有三种，第一种是使用闭包的方式</p>
<pre><code class="hljs js" lang="js"><span class="hljs-keyword">for</span> (<span class="hljs-keyword">var</span> i = <span class="hljs-number">1</span>; i &lt;= <span class="hljs-number">5</span>; i++) {
  ;(<span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params">j</span>) </span>{
    setTimeout(<span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">timer</span>(<span class="hljs-params"></span>) </span>{
      <span class="hljs-built_in">console</span>.log(j)
    }, j * <span class="hljs-number">1000</span>)
  })(i)
}
</code></pre><p>在上述代码中，我们首先使用了立即执行函数将 <code>i</code> 传入函数内部，这个时候值就被固定在了参数 <code>j</code> 上面不会改变，当下次执行 <code>timer</code> 这个闭包的时候，就可以使用外部函数的变量 <code>j</code>，从而达到目的。</p>
<p>第二种就是使用 <code>setTimeout</code> 的第三个参数，这个参数会被当成 <code>timer</code> 函数的参数传入。</p>
<pre><code class="hljs js" lang="js"><span class="hljs-keyword">for</span> (<span class="hljs-keyword">var</span> i = <span class="hljs-number">1</span>; i &lt;= <span class="hljs-number">5</span>; i++) {
  setTimeout(
    <span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">timer</span>(<span class="hljs-params">j</span>) </span>{
      <span class="hljs-built_in">console</span>.log(j)
    },
    i * <span class="hljs-number">1000</span>,
    i
  )
}
</code></pre><p>第三种就是使用 <code>let</code> 定义 <code>i</code> 了来解决问题了，这个也是最为推荐的方式</p>
<pre><code class="hljs js" lang="js"><span class="hljs-keyword">for</span> (<span class="hljs-keyword">let</span> i = <span class="hljs-number">1</span>; i &lt;= <span class="hljs-number">5</span>; i++) {
  setTimeout(<span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">timer</span>(<span class="hljs-params"></span>) </span>{
    <span class="hljs-built_in">console</span>.log(i)
  }, i * <span class="hljs-number">1000</span>)
}
</code></pre><h2 class="heading" data-id="heading-3">深浅拷贝</h2>
<blockquote class="warning"><p>涉及面试题：什么是浅拷贝？如何实现浅拷贝？什么是深拷贝？如何实现深拷贝？
</p></blockquote><p>在上一章节中，我们了解了对象类型在赋值的过程中其实是复制了地址，从而会导致改变了一方其他也都被改变的情况。通常在开发中我们不希望出现这样的问题，我们可以使用浅拷贝来解决这个情况。</p>
<pre><code class="hljs js" lang="js"><span class="hljs-keyword">let</span> a = {
  <span class="hljs-attr">age</span>: <span class="hljs-number">1</span>
}
<span class="hljs-keyword">let</span> b = a
a.age = <span class="hljs-number">2</span>
<span class="hljs-built_in">console</span>.log(b.age) <span class="hljs-comment">// 2</span>
</code></pre><h3 class="heading" data-id="heading-4">浅拷贝</h3>
<p>首先可以通过 <code>Object.assign</code> 来解决这个问题，很多人认为这个函数是用来深拷贝的。其实并不是，<code>Object.assign</code> 只会拷贝所有的属性值到新的对象中，如果属性值是对象的话，拷贝的是地址，所以并不是深拷贝。</p>
<pre><code class="hljs js" lang="js"><span class="hljs-keyword">let</span> a = {
  <span class="hljs-attr">age</span>: <span class="hljs-number">1</span>
}
<span class="hljs-keyword">let</span> b = <span class="hljs-built_in">Object</span>.assign({}, a)
a.age = <span class="hljs-number">2</span>
<span class="hljs-built_in">console</span>.log(b.age) <span class="hljs-comment">// 1</span>
</code></pre><p>另外我们还可以通过展开运算符 <code>...</code> 来实现浅拷贝</p>
<pre><code class="hljs js" lang="js"><span class="hljs-keyword">let</span> a = {
  <span class="hljs-attr">age</span>: <span class="hljs-number">1</span>
}
<span class="hljs-keyword">let</span> b = { ...a }
a.age = <span class="hljs-number">2</span>
<span class="hljs-built_in">console</span>.log(b.age) <span class="hljs-comment">// 1</span>
</code></pre><p>通常浅拷贝就能解决大部分问题了，但是当我们遇到如下情况就可能需要使用到深拷贝了</p>
<pre><code class="hljs js" lang="js"><span class="hljs-keyword">let</span> a = {
  <span class="hljs-attr">age</span>: <span class="hljs-number">1</span>,
  <span class="hljs-attr">jobs</span>: {
    <span class="hljs-attr">first</span>: <span class="hljs-string">'FE'</span>
  }
}
<span class="hljs-keyword">let</span> b = { ...a }
a.jobs.first = <span class="hljs-string">'native'</span>
<span class="hljs-built_in">console</span>.log(b.jobs.first) <span class="hljs-comment">// native</span>
</code></pre><p>浅拷贝只解决了第一层的问题，如果接下去的值中还有对象的话，那么就又回到最开始的话题了，两者享有相同的地址。要解决这个问题，我们就得使用深拷贝了。</p>
<h3 class="heading" data-id="heading-5">深拷贝</h3>
<p>这个问题通常可以通过 <code>JSON.parse(JSON.stringify(object))</code> 来解决。</p>
<pre><code class="hljs js" lang="js"><span class="hljs-keyword">let</span> a = {
  <span class="hljs-attr">age</span>: <span class="hljs-number">1</span>,
  <span class="hljs-attr">jobs</span>: {
    <span class="hljs-attr">first</span>: <span class="hljs-string">'FE'</span>
  }
}
<span class="hljs-keyword">let</span> b = <span class="hljs-built_in">JSON</span>.parse(<span class="hljs-built_in">JSON</span>.stringify(a))
a.jobs.first = <span class="hljs-string">'native'</span>
<span class="hljs-built_in">console</span>.log(b.jobs.first) <span class="hljs-comment">// FE</span>
</code></pre><p>但是该方法也是有局限性的：</p>
<ul>
<li>会忽略 <code>undefined</code></li>
<li>会忽略 <code>symbol</code></li>
<li>不能序列化函数</li>
<li>不能解决循环引用的对象</li>
</ul>
<pre><code class="hljs js" lang="js"><span class="hljs-keyword">let</span> obj = {
  <span class="hljs-attr">a</span>: <span class="hljs-number">1</span>,
  <span class="hljs-attr">b</span>: {
    <span class="hljs-attr">c</span>: <span class="hljs-number">2</span>,
    <span class="hljs-attr">d</span>: <span class="hljs-number">3</span>,
  },
}
obj.c = obj.b
obj.e = obj.a
obj.b.c = obj.c
obj.b.d = obj.b
obj.b.e = obj.b.c
<span class="hljs-keyword">let</span> newObj = <span class="hljs-built_in">JSON</span>.parse(<span class="hljs-built_in">JSON</span>.stringify(obj))
<span class="hljs-built_in">console</span>.log(newObj)
</code></pre><p>如果你有这么一个循环引用对象，你会发现并不能通过该方法实现深拷贝</p>
<p></p><figure><img class="lazyload inited" data-src="https://user-gold-cdn.xitu.io/2018/3/28/1626b1ec2d3f9e41?imageView2/0/w/1280/h/960/format/webp/ignore-error/1" data-width="840" data-height="100" src="data:image/svg+xml;utf8,&lt;?xml version=&quot;1.0&quot;?&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; version=&quot;1.1&quot; width=&quot;840&quot; height=&quot;100&quot;&gt;&lt;/svg&gt;"><figcaption></figcaption></figure><p></p>
<p>在遇到函数、 <code>undefined</code> 或者 <code>symbol</code> 的时候，该对象也不能正常的序列化</p>
<pre><code class="hljs js" lang="js"><span class="hljs-keyword">let</span> a = {
  <span class="hljs-attr">age</span>: <span class="hljs-literal">undefined</span>,
  <span class="hljs-attr">sex</span>: <span class="hljs-built_in">Symbol</span>(<span class="hljs-string">'male'</span>),
  <span class="hljs-attr">jobs</span>: <span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params"></span>) </span>{},
  <span class="hljs-attr">name</span>: <span class="hljs-string">'yck'</span>
}
<span class="hljs-keyword">let</span> b = <span class="hljs-built_in">JSON</span>.parse(<span class="hljs-built_in">JSON</span>.stringify(a))
<span class="hljs-built_in">console</span>.log(b) <span class="hljs-comment">// {name: "yck"}</span>
</code></pre><p>你会发现在上述情况中，该方法会忽略掉函数和 <code>undefined</code> 。</p>
<p>但是在通常情况下，复杂数据都是可以序列化的，所以这个函数可以解决大部分问题。</p>
<p>如果你所需拷贝的对象含有内置类型并且不包含函数，可以使用 <code>MessageChannel</code></p>
<pre><code class="hljs js" lang="js"><span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">structuralClone</span>(<span class="hljs-params">obj</span>) </span>{
  <span class="hljs-keyword">return</span> <span class="hljs-keyword">new</span> <span class="hljs-built_in">Promise</span>(<span class="hljs-function"><span class="hljs-params">resolve</span> =&gt;</span> {
    <span class="hljs-keyword">const</span> { port1, port2 } = <span class="hljs-keyword">new</span> MessageChannel()
    port2.onmessage = <span class="hljs-function"><span class="hljs-params">ev</span> =&gt;</span> resolve(ev.data)
    port1.postMessage(obj)
  })
}

<span class="hljs-keyword">var</span> obj = {
  <span class="hljs-attr">a</span>: <span class="hljs-number">1</span>,
  <span class="hljs-attr">b</span>: {
    <span class="hljs-attr">c</span>: <span class="hljs-number">2</span>
  }
}

obj.b.d = obj.b

<span class="hljs-comment">// 注意该方法是异步的</span>
<span class="hljs-comment">// 可以处理 undefined 和循环引用对象</span>
<span class="hljs-keyword">const</span> test = <span class="hljs-keyword">async</span> () =&gt; {
  <span class="hljs-keyword">const</span> clone = <span class="hljs-keyword">await</span> structuralClone(obj)
  <span class="hljs-built_in">console</span>.log(clone)
}
test()
</code></pre><p>当然你可能想自己来实现一个深拷贝，但是其实实现一个深拷贝是很困难的，需要我们考虑好多种边界情况，比如原型链如何处理、DOM 如何处理等等，所以这里我们实现的深拷贝只是简易版，并且我其实更推荐使用 <a target="_blank" href="https://link.juejin.im/?target=https%3A%2F%2Flodash.com%2Fdocs%23cloneDeep" rel="nofollow noopener noreferrer">lodash 的深拷贝函数</a>。</p>
<pre><code class="hljs js" lang="js"><span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">deepClone</span>(<span class="hljs-params">obj</span>) </span>{
  <span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">isObject</span>(<span class="hljs-params">o</span>) </span>{
    <span class="hljs-keyword">return</span> (<span class="hljs-keyword">typeof</span> o === <span class="hljs-string">'object'</span> || <span class="hljs-keyword">typeof</span> o === <span class="hljs-string">'function'</span>) &amp;&amp; o !== <span class="hljs-literal">null</span>
  }

  <span class="hljs-keyword">if</span> (!isObject(obj)) {
    <span class="hljs-keyword">throw</span> <span class="hljs-keyword">new</span> <span class="hljs-built_in">Error</span>(<span class="hljs-string">'非对象'</span>)
  }

  <span class="hljs-keyword">let</span> isArray = <span class="hljs-built_in">Array</span>.isArray(obj)
  <span class="hljs-keyword">let</span> newObj = isArray ? [...obj] : { ...obj }
  <span class="hljs-built_in">Reflect</span>.ownKeys(newObj).forEach(<span class="hljs-function"><span class="hljs-params">key</span> =&gt;</span> {
    newObj[key] = isObject(obj[key]) ? deepClone(obj[key]) : obj[key]
  })

  <span class="hljs-keyword">return</span> newObj
}

<span class="hljs-keyword">let</span> obj = {
  <span class="hljs-attr">a</span>: [<span class="hljs-number">1</span>, <span class="hljs-number">2</span>, <span class="hljs-number">3</span>],
  <span class="hljs-attr">b</span>: {
    <span class="hljs-attr">c</span>: <span class="hljs-number">2</span>,
    <span class="hljs-attr">d</span>: <span class="hljs-number">3</span>
  }
}
<span class="hljs-keyword">let</span> newObj = deepClone(obj)
newObj.b.c = <span class="hljs-number">1</span>
<span class="hljs-built_in">console</span>.log(obj.b.c) <span class="hljs-comment">// 2</span>
</code></pre><h2 class="heading" data-id="heading-6">原型</h2>
<blockquote class="warning"><p>涉及面试题：如何理解原型？如何理解原型链？
</p></blockquote><p>当我们创建一个对象时 <code>let obj = { age: 25 }</code>，我们可以发现能使用很多种函数，但是我们明明没有定义过它们，对于这种情况你是否有过疑惑？</p>
<p></p><figure><img class="lazyload inited" data-src="https://user-gold-cdn.xitu.io/2018/11/16/1671d15f45fcedea?imageView2/0/w/1280/h/960/format/webp/ignore-error/1" data-width="800" data-height="600" src="data:image/svg+xml;utf8,&lt;?xml version=&quot;1.0&quot;?&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; version=&quot;1.1&quot; width=&quot;800&quot; height=&quot;600&quot;&gt;&lt;/svg&gt;"><figcaption></figcaption></figure><p></p>
<p>当我们在浏览器中打印 <code>obj</code> 时你会发现，在 <code>obj</code> 上居然还有一个 <code>__proto__</code> 属性，那么看来之前的疑问就和这个属性有关系了。</p>
<p>其实每个 JS 对象都有 <code>__proto__</code> 属性，这个属性指向了原型。这个属性在现在来说已经不推荐直接去使用它了，这只是浏览器在早期为了让我们访问到内部属性 <code>[[prototype]]</code> 来实现的一个东西。</p>
<p>讲到这里好像还是没有弄明白什么是原型，接下来让我们再看看 <code>__proto__</code> 里面有什么吧。</p>
<p></p><figure><img class="lazyload inited" data-src="https://user-gold-cdn.xitu.io/2018/11/16/1671d2c5a6bcccc4?imageView2/0/w/1280/h/960/format/webp/ignore-error/1" data-width="383" data-height="271" src="data:image/svg+xml;utf8,&lt;?xml version=&quot;1.0&quot;?&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; version=&quot;1.1&quot; width=&quot;383&quot; height=&quot;271&quot;&gt;&lt;/svg&gt;"><figcaption></figcaption></figure><p></p>
<p>看到这里你应该明白了，原型也是一个对象，并且这个对象中包含了很多函数，所以我们可以得出一个结论：对于 <code>obj</code> 来说，可以通过 <code>__proto__</code> 找到一个原型对象，在该对象中定义了很多函数让我们来使用。</p>
<p>在上面的图中我们还可以发现一个 <code>constructor</code> 属性，也就是构造函数</p>
<p></p><figure><img class="lazyload inited" data-src="https://user-gold-cdn.xitu.io/2018/11/16/1671d329ec98ec0b?imageView2/0/w/1280/h/960/format/webp/ignore-error/1" data-width="581" data-height="404" src="data:image/svg+xml;utf8,&lt;?xml version=&quot;1.0&quot;?&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; version=&quot;1.1&quot; width=&quot;581&quot; height=&quot;404&quot;&gt;&lt;/svg&gt;"><figcaption></figcaption></figure><p></p>
<p>打开 <code>constructor</code> 属性我们又可以发现其中还有一个 <code>prototype</code> 属性，并且这个属性对应的值和先前我们在 <code>__proto__</code> 中看到的一模一样。所以我们又可以得出一个结论：原型的 <code>constructor</code> 属性指向构造函数，构造函数又通过 <code>prototype</code> 属性指回原型，但是并不是所有函数都具有这个属性，<code>Function.prototype.bind()</code> 就没有这个属性。</p>
<p>其实原型就是那么简单，接下来我们再来看一张图，相信这张图能让你彻底明白原型和原型链</p>
<p></p><figure><img class="lazyload inited" data-src="https://user-gold-cdn.xitu.io/2018/11/16/1671d387e4189ec8?imageView2/0/w/1280/h/960/format/webp/ignore-error/1" data-width="618" data-height="781" src="data:image/svg+xml;utf8,&lt;?xml version=&quot;1.0&quot;?&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; version=&quot;1.1&quot; width=&quot;618&quot; height=&quot;781&quot;&gt;&lt;/svg&gt;"><figcaption></figcaption></figure><p></p>
<p>看完这张图，我再来解释下什么是原型链吧。其实原型链就是多个对象通过 <code>__proto__</code> 的方式连接了起来。为什么 <code>obj</code> 可以访问到 <code>valueOf</code> 函数，就是因为 <code>obj</code> 通过原型链找到了 <code>valueOf</code> 函数。</p>
<p>对于这一小节的知识点，总结起来就是以下几点：</p>
<ul>
<li><code>Object</code> 是所有对象的爸爸，所有对象都可以通过 <code>__proto__</code> 找到它</li>
<li><code>Function</code> 是所有函数的爸爸，所有函数都可以通过 <code>__proto__</code> 找到它</li>
<li>函数的 <code>prototype</code> 是一个对象</li>
<li>对象的 <code>__proto__</code> 属性指向原型， <code>__proto__</code> 将对象和原型连接起来组成了原型链</li>
</ul>
<h2 class="heading" data-id="heading-7">小结</h2>
<p>以上就是全部的常考和容易混乱的基础知识点了，下一章节我们将会学习 ES6 部分的知识。如果大家对于这个章节的内容存在疑问，欢迎在评论区与我互动。</p>
</div><section data-v-ecce5e7e="" class="book-comments"><div data-v-ecce5e7e="" class="box-title">留言</div><div data-v-ecce5e7e="" class="comment-box"><div data-v-1146c0e6="" data-v-ecce5e7e="" class="comment-form comment-form" id="comment"><div data-v-57c47624="" data-v-cf310dfc="" data-v-1146c0e6="" data-src="https://avatars0.githubusercontent.com/u/33979626?v=4" class="lazy avatar avatar loaded" style="background-image: url(&quot;https://avatars0.githubusercontent.com/u/33979626?v=4&quot;);"></div><textarea data-v-1146c0e6="" placeholder="评论将在后台进行审核，审核通过后对所有人可见" class="content-input" style="overflow: hidden; overflow-wrap: break-word; height: 60px;"></textarea><div data-v-1146c0e6="" class="action-box" style="display: none;"><div data-v-627e3889="" data-v-1146c0e6="" class="image-uploader image-uploader" style="display: none;"><input data-v-627e3889="" type="file" class="input"><button data-v-627e3889="" class="upload-btn"><i data-v-627e3889="" class="icon ion-image"></i><span data-v-627e3889="">上传图片</span></button></div><div data-v-1146c0e6="" class="submit-box"><span data-v-1146c0e6="" class="submit-text">Ctrl or ⌘ + Enter</span><button data-v-1146c0e6="" class="submit-btn">评论</button></div></div><!----></div></div><ul data-v-6adae277="" data-v-ecce5e7e="" st:block="commentList" class="comment-list comment-list"><li data-v-6adae277="" class="item"><div data-v-38783431="" data-v-6adae277="" class="comment"><div data-v-3a6943ce="" data-v-38783431="" st:block="userPopover" st:state="5c2c190ee51d455405559168" class="user-popover-box"><!----><a data-v-38783431="" href="https://juejin.im/user/5c2c190ee51d455405559168" target="_blank" rel="" data-v-3a6943ce=""><div data-v-57c47624="" data-v-cf310dfc="" data-v-38783431="" data-src="https://thirdwx.qlogo.cn/mmopen/vi_32/nz64yEN9S1icXvqH1WPU8bBBaxmOicQia8tYDMZJ4ottKcs6hgp29eX1pe836OibYINOKsteibRibdt4icJo3VkwibX3UQ/132" class="lazy avatar avatar" style="background-image: none;"></div></a></div><div data-v-38783431="" class="content-box"><div data-v-38783431="" class="header"><div data-v-38783431="" class="user-info"><div data-v-3a6943ce="" data-v-38783431="" st:block="userPopover" st:state="5c2c190ee51d455405559168" class="user-popover-box"><!----><a data-v-38783431="" href="https://juejin.im/user/5c2c190ee51d455405559168" target="_blank" rel="" class="username" data-v-3a6943ce="">Mr  T</a></div><div data-v-38783431="" class="position"></div></div></div><div data-v-38783431="" class="content"><!----><span data-v-38783431="" class="content-html">如果一个是对象，另一个是数值或字符串，把对象转换成基础类型的值再比较。对象转换成基础类型，利用它的toString或者valueOf方法。 js核心内置类，会尝试valueOf先于toString；例外的是Date，Date利用的是toString转换</span><!----></div><div data-v-38783431="" class="footer"><button data-v-38783431="" class="like-btn"><i data-v-38783431="" class="collection-arrow-ion ion-arrow-up-b"></i><span data-v-38783431="">0</span></button><span data-v-38783431="" class="sub-comment-btn text-pointer"><span data-v-38783431="" class="title">评论</span><div data-v-38783431="" class="sub-comment--arrow" style="display: none;"></div></span><span data-v-38783431="" class="date">7小时前</span><!----></div><!----></div><!----></div></li><li data-v-6adae277="" class="item"><div data-v-38783431="" data-v-6adae277="" class="comment"><div data-v-3a6943ce="" data-v-38783431="" st:block="userPopover" st:state="57600e716be3ff006afe6d20" class="user-popover-box"><!----><a data-v-38783431="" href="https://juejin.im/user/57600e716be3ff006afe6d20" target="_blank" rel="" data-v-3a6943ce=""><div data-v-57c47624="" data-v-cf310dfc="" data-v-38783431="" data-src="https://user-gold-cdn.xitu.io/2016/11/29/358d5b7b4dc58f594888a2487d2b0e60?imageView2/1/w/100/h/100/q/85/format/webp/interlace/1" class="lazy avatar avatar" style="background-image: none;"></div></a></div><div data-v-38783431="" class="content-box"><div data-v-38783431="" class="header"><div data-v-38783431="" class="user-info"><div data-v-3a6943ce="" data-v-38783431="" st:block="userPopover" st:state="57600e716be3ff006afe6d20" class="user-popover-box"><!----><a data-v-38783431="" href="https://juejin.im/user/57600e716be3ff006afe6d20" target="_blank" rel="" class="username" data-v-3a6943ce="">DarkSnow</a></div><div data-v-38783431="" class="position">前端工程师</div></div></div><div data-v-38783431="" class="content"><!----><span data-v-38783431="" class="content-html">打印出来看了以下，Function.prototype.call/apply/bind 是都不存在prototype属性的</span><!----></div><div data-v-38783431="" class="footer"><button data-v-38783431="" class="like-btn"><i data-v-38783431="" class="collection-arrow-ion ion-arrow-up-b"></i><span data-v-38783431="">0</span></button><span data-v-38783431="" class="sub-comment-btn text-pointer"><span data-v-38783431="" class="title">评论</span><div data-v-38783431="" class="sub-comment--arrow" style="display: none;"></div></span><span data-v-38783431="" class="date">1天前</span><!----></div><!----></div><!----></div></li><li data-v-6adae277="" class="item"><div data-v-38783431="" data-v-6adae277="" class="comment"><div data-v-3a6943ce="" data-v-38783431="" st:block="userPopover" st:state="5aa8a8886fb9a028e11fa552" class="user-popover-box"><!----><a data-v-38783431="" href="https://juejin.im/user/5aa8a8886fb9a028e11fa552" target="_blank" rel="" data-v-3a6943ce=""><div data-v-57c47624="" data-v-cf310dfc="" data-v-38783431="" data-src="https://thirdwx.qlogo.cn/mmopen/vi_32/cq9Ab16r2KcEJ9xQibSyT8G6lHZFPcdDpVcW9sYg3KUlaBEewRELsj40eCpHIN9KJDLjf86YrDOicA8qKxerKuwA/132" class="lazy avatar avatar" style="background-image: none;"></div></a></div><div data-v-38783431="" class="content-box"><div data-v-38783431="" class="header"><div data-v-38783431="" class="user-info"><div data-v-3a6943ce="" data-v-38783431="" st:block="userPopover" st:state="5aa8a8886fb9a028e11fa552" class="user-popover-box"><!----><a data-v-38783431="" href="https://juejin.im/user/5aa8a8886fb9a028e11fa552" target="_blank" rel="" class="username" data-v-3a6943ce="">茶丶清味</a></div><div data-v-38783431="" class="position"></div></div></div><div data-v-38783431="" class="content"><!----><span data-v-38783431="" class="content-html">并不是所有函数都具有这个属性，Function.prototype.bind() 就没有这个属性。？？这张图明明显示有这个属性哦！怎么回事？</span><!----></div><div data-v-38783431="" class="footer"><button data-v-38783431="" class="like-btn"><i data-v-38783431="" class="collection-arrow-ion ion-arrow-up-b"></i><span data-v-38783431="">0</span></button><span data-v-38783431="" class="sub-comment-btn text-pointer"><span data-v-38783431="" class="title">评论</span><div data-v-38783431="" class="sub-comment--arrow" style="display: none;"></div></span><span data-v-38783431="" class="date">5天前</span><!----></div><!----></div><!----></div></li><li data-v-6adae277="" class="item"><div data-v-38783431="" data-v-6adae277="" class="comment"><div data-v-3a6943ce="" data-v-38783431="" st:block="userPopover" st:state="5aabee6d5188255587235137" class="user-popover-box"><!----><a data-v-38783431="" href="https://juejin.im/user/5aabee6d5188255587235137" target="_blank" rel="" data-v-3a6943ce=""><div data-v-57c47624="" data-v-cf310dfc="" data-v-38783431="" data-src="https://user-gold-cdn.xitu.io/2018/9/2/165993c40c6ef0e5?imageView2/1/w/100/h/100/q/85/format/webp/interlace/1" class="lazy avatar avatar" style="background-image: none;"></div></a></div><div data-v-38783431="" class="content-box"><div data-v-38783431="" class="header"><div data-v-38783431="" class="user-info"><div data-v-3a6943ce="" data-v-38783431="" st:block="userPopover" st:state="5aabee6d5188255587235137" class="user-popover-box"><!----><a data-v-38783431="" href="https://juejin.im/user/5aabee6d5188255587235137" target="_blank" rel="" class="username" data-v-3a6943ce="">kingll</a></div><div data-v-38783431="" class="position">web前端</div></div></div><div data-v-38783431="" class="content"><!----><span data-v-38783431="" class="content-html">Function.prototype.bind() 没有prototype 怎么理解啊</span><!----></div><div data-v-38783431="" class="footer"><button data-v-38783431="" class="like-btn"><i data-v-38783431="" class="collection-arrow-ion ion-arrow-up-b"></i><span data-v-38783431="">0</span></button><span data-v-38783431="" class="sub-comment-btn text-pointer"><span data-v-38783431="" class="title">评论</span><div data-v-38783431="" class="sub-comment--arrow" style="display: none;"></div></span><span data-v-38783431="" class="date">5天前</span><!----></div><!----></div><!----></div></li><li data-v-6adae277="" class="item"><div data-v-38783431="" data-v-6adae277="" class="comment"><div data-v-3a6943ce="" data-v-38783431="" st:block="userPopover" st:state="59252e4c0ce463006978945b" class="user-popover-box"><!----><a data-v-38783431="" href="https://juejin.im/user/59252e4c0ce463006978945b" target="_blank" rel="" data-v-3a6943ce=""><div data-v-57c47624="" data-v-cf310dfc="" data-v-38783431="" data-src="https://user-gold-cdn.xitu.io/2017/8/3/f405b4f3166441cb7251fbfce80f5eb7?imageView2/1/w/100/h/100/q/85/format/webp/interlace/1" class="lazy avatar avatar" style="background-image: none;"></div></a></div><div data-v-38783431="" class="content-box"><div data-v-38783431="" class="header"><div data-v-38783431="" class="user-info"><div data-v-3a6943ce="" data-v-38783431="" st:block="userPopover" st:state="59252e4c0ce463006978945b" class="user-popover-box"><!----><a data-v-38783431="" href="https://juejin.im/user/59252e4c0ce463006978945b" target="_blank" rel="" class="username" data-v-3a6943ce="">我母鸡啊！</a></div><div data-v-38783431="" class="position">前端小菜鸡 @ 2dfire</div></div></div><div data-v-38783431="" class="content"><!----><span data-v-38783431="" class="content-html">console.log([] == ![]) //true
我觉得是两边要转成同样的基本类型在做比较，Number(![]) = 0 ,Number([]) = 0 。所以 ![] == [] //true</span><!----></div><div data-v-38783431="" class="footer"><button data-v-38783431="" class="like-btn"><i data-v-38783431="" class="collection-arrow-ion ion-arrow-up-b"></i><span data-v-38783431="">3</span></button><span data-v-38783431="" class="sub-comment-btn text-pointer"><span data-v-38783431="" class="title">评论</span><div data-v-38783431="" class="sub-comment--arrow" style="display: none;"></div></span><span data-v-38783431="" class="date">11天前</span><!----></div><!----></div><!----></div></li><li data-v-6adae277="" class="item"><div data-v-38783431="" data-v-6adae277="" class="comment"><div data-v-3a6943ce="" data-v-38783431="" st:block="userPopover" st:state="593662c8ac502e0068beffea" class="user-popover-box"><!----><a data-v-38783431="" href="https://juejin.im/user/593662c8ac502e0068beffea" target="_blank" rel="" data-v-3a6943ce=""><div data-v-57c47624="" data-v-cf310dfc="" data-v-38783431="" data-src="https://user-gold-cdn.xitu.io/2018/11/13/1670c0de2848b0fd?imageView2/1/w/100/h/100/q/85/format/webp/interlace/1" class="lazy avatar avatar" style="background-image: none;"></div></a></div><div data-v-38783431="" class="content-box"><div data-v-38783431="" class="header"><div data-v-38783431="" class="user-info"><div data-v-3a6943ce="" data-v-38783431="" st:block="userPopover" st:state="593662c8ac502e0068beffea" class="user-popover-box"><!----><a data-v-38783431="" href="https://juejin.im/user/593662c8ac502e0068beffea" target="_blank" rel="" class="username" data-v-3a6943ce="">这就是我的偶像</a></div><div data-v-38783431="" class="position">前端 @ 黑作坊</div></div></div><div data-v-38783431="" class="content"><!----><span data-v-38783431="" class="content-html">for (let i = 1; i &lt;= 5; i++) {
  setTimeout(function timer() {
    console.log(i)
  }, i * 1000)
}
知道这样能解决，但是不知道为什么能解决，用个哪点知识，求大神解答</span><!----></div><div data-v-38783431="" class="footer"><button data-v-38783431="" class="like-btn"><i data-v-38783431="" class="collection-arrow-ion ion-arrow-up-b"></i><span data-v-38783431="">0</span></button><span data-v-38783431="" class="sub-comment-btn text-pointer"><span data-v-38783431="" class="title">收起评论</span><div data-v-38783431="" class="sub-comment--arrow" style=""></div></span><span data-v-38783431="" class="date">12天前</span><!----></div><div data-v-4afc11f9="" data-v-38783431="" class="sub-comment-box sub-comment-box"><div data-v-4afc11f9="" class="sub-comment-box__top"><div data-v-4afc11f9="" class="icon-close"></div><h3 data-v-4afc11f9="">评论</h3></div><div data-v-4afc11f9="" class="sub-comment-box__inner"><div data-v-4afc11f9=""><ul data-v-4afc11f9="" class="sub-comment-list"><li data-v-4afc11f9="" class="item"><div data-v-6fd44370="" data-v-4afc11f9="" class="sub-comment sub-comment"><div data-v-3a6943ce="" data-v-6fd44370="" st:block="userPopover" st:state="5c21e1af5188252eb759742c" class="user-popover-box user-popover--avatar"><!----><div data-v-57c47624="" data-v-cf310dfc="" data-v-6fd44370="" data-src="https://user-gold-cdn.xitu.io/2018/12/25/167e45b65bd89307?imageView2/1/w/100/h/100/q/85/format/webp/interlace/1" class="lazy avatar avatar" data-v-3a6943ce="" style="background-image: none;"></div></div><div data-v-6fd44370="" class="content-box"><div data-v-6fd44370="" class="header"><div data-v-6fd44370="" class="user-info"><div data-v-3a6943ce="" data-v-6fd44370="" st:block="userPopover" st:state="5c21e1af5188252eb759742c" class="user-popover-box user-popover--info"><!----><a data-v-6fd44370="" href="https://juejin.im/user/5c21e1af5188252eb759742c" target="_blank" rel="" class="username" data-v-3a6943ce="">橙子cjw</a></div><div data-v-6fd44370="" class="position"></div></div></div><div data-v-6fd44370="" class="content"><!----><span data-v-6fd44370="" class="content-html">去看一下es6 let作用域</span><!----></div><div data-v-6fd44370="" class="footer"><span data-v-6fd44370="" class="date">11天前</span><a data-v-6fd44370="" class="reply-btn">回复</a><!----></div></div><!----></div></li><li data-v-4afc11f9="" class="item"><div data-v-6fd44370="" data-v-4afc11f9="" class="sub-comment sub-comment"><div data-v-3a6943ce="" data-v-6fd44370="" st:block="userPopover" st:state="598cfa26f265da3e0e1065e4" class="user-popover-box user-popover--avatar"><!----><div data-v-57c47624="" data-v-cf310dfc="" data-v-6fd44370="" data-src="https://user-gold-cdn.xitu.io/2018/7/25/164cf59ef8fbe5b4?imageView2/1/w/100/h/100/q/85/format/webp/interlace/1" class="lazy avatar avatar" data-v-3a6943ce="" style="background-image: none;"></div></div><div data-v-6fd44370="" class="content-box"><div data-v-6fd44370="" class="header"><div data-v-6fd44370="" class="user-info"><div data-v-3a6943ce="" data-v-6fd44370="" st:block="userPopover" st:state="598cfa26f265da3e0e1065e4" class="user-popover-box user-popover--info"><!----><a data-v-6fd44370="" href="https://juejin.im/user/598cfa26f265da3e0e1065e4" target="_blank" rel="" class="username" data-v-3a6943ce="">李雨冰</a></div><div data-v-6fd44370="" class="position">前端 @ MYCOMPANY</div></div></div><div data-v-6fd44370="" class="content"><!----><span data-v-6fd44370="" class="content-html">let 声明变量的作用域问题</span><!----></div><div data-v-6fd44370="" class="footer"><span data-v-6fd44370="" class="date">11天前</span><a data-v-6fd44370="" class="reply-btn">回复</a><!----></div></div><!----></div></li><li data-v-4afc11f9="" class="item"><div data-v-6fd44370="" data-v-4afc11f9="" class="sub-comment sub-comment"><div data-v-3a6943ce="" data-v-6fd44370="" st:block="userPopover" st:state="5c232655518825480635cb2d" class="user-popover-box user-popover--avatar"><!----><div data-v-57c47624="" data-v-cf310dfc="" data-v-6fd44370="" data-src="https://user-gold-cdn.xitu.io/2018/12/26/167e94f8c95f19e5?imageView2/1/w/100/h/100/q/85/format/webp/interlace/1" class="lazy avatar avatar" data-v-3a6943ce="" style="background-image: none;"></div></div><div data-v-6fd44370="" class="content-box"><div data-v-6fd44370="" class="header"><div data-v-6fd44370="" class="user-info"><div data-v-3a6943ce="" data-v-6fd44370="" st:block="userPopover" st:state="5c232655518825480635cb2d" class="user-popover-box user-popover--info"><!----><a data-v-6fd44370="" href="https://juejin.im/user/5c232655518825480635cb2d" target="_blank" rel="" class="username" data-v-3a6943ce="">wen_qiang</a></div><div data-v-6fd44370="" class="position">前端工程师</div></div></div><div data-v-6fd44370="" class="content"><!----><span data-v-6fd44370="" class="content-html">es6 中 let声明的变量作用于只在当前函数</span><!----></div><div data-v-6fd44370="" class="footer"><span data-v-6fd44370="" class="date">11天前</span><a data-v-6fd44370="" class="reply-btn">回复</a><!----></div></div><!----></div></li><li data-v-4afc11f9="" class="item"><div data-v-6fd44370="" data-v-4afc11f9="" class="sub-comment sub-comment"><div data-v-3a6943ce="" data-v-6fd44370="" st:block="userPopover" st:state="59ba13fb5188256bd733c149" class="user-popover-box user-popover--avatar"><!----><div data-v-57c47624="" data-v-cf310dfc="" data-v-6fd44370="" data-src="https://wx.qlogo.cn/mmopen/vi_32/icRMfxTtOCJWk0s4OJh1WbIicmhyJt9yiayXN0vyNGsibjvrD0DQIplOneJ92IdDKv0JicRXNTnkAlu5uOibfJhdtH8Q/0" class="lazy avatar avatar" data-v-3a6943ce="" style="background-image: none;"></div></div><div data-v-6fd44370="" class="content-box"><div data-v-6fd44370="" class="header"><div data-v-6fd44370="" class="user-info"><div data-v-3a6943ce="" data-v-6fd44370="" st:block="userPopover" st:state="59ba13fb5188256bd733c149" class="user-popover-box user-popover--info"><!----><a data-v-6fd44370="" href="https://juejin.im/user/59ba13fb5188256bd733c149" target="_blank" rel="" class="username" data-v-3a6943ce="">闹闹不爱闹</a></div><div data-v-6fd44370="" class="position"></div></div></div><div data-v-6fd44370="" class="content"><!----><span data-v-6fd44370="" class="content-html">说实话，知道let是声明的是块级作用域的变量，但是还是不知道为什么能解决这个问题</span><!----></div><div data-v-6fd44370="" class="footer"><span data-v-6fd44370="" class="date">11天前</span><a data-v-6fd44370="" class="reply-btn">回复</a><!----></div></div><!----></div></li><li data-v-4afc11f9="" class="item"><div data-v-6fd44370="" data-v-4afc11f9="" class="sub-comment sub-comment"><div data-v-3a6943ce="" data-v-6fd44370="" st:block="userPopover" st:state="5b987c0b6fb9a05cf22fdfb4" class="user-popover-box user-popover--avatar"><!----><div data-v-57c47624="" data-v-cf310dfc="" data-v-6fd44370="" data-src="https://thirdwx.qlogo.cn/mmopen/vi_32/8SpBA9A4Q4lCBnjGRwVrFqhmkUaS5yQD22YEfPw24riasKPorx8kFnNoxyW6epSW7zoR6KGqiaJg8LCmzzqicet3A/132" class="lazy avatar avatar" data-v-3a6943ce="" style="background-image: none;"></div></div><div data-v-6fd44370="" class="content-box"><div data-v-6fd44370="" class="header"><div data-v-6fd44370="" class="user-info"><div data-v-3a6943ce="" data-v-6fd44370="" st:block="userPopover" st:state="5b987c0b6fb9a05cf22fdfb4" class="user-popover-box user-popover--info"><!----><a data-v-6fd44370="" href="https://juejin.im/user/5b987c0b6fb9a05cf22fdfb4" target="_blank" rel="" class="username" data-v-3a6943ce="">大恐龙</a></div><div data-v-6fd44370="" class="position"></div></div></div><div data-v-6fd44370="" class="content"><!----><span data-v-6fd44370="" class="content-html">要是改成var，应该会更好理解一点吧</span><!----></div><div data-v-6fd44370="" class="footer"><span data-v-6fd44370="" class="date">7天前</span><a data-v-6fd44370="" class="reply-btn">回复</a><!----></div></div><!----></div></li></ul><ul data-v-5d3e9a75="" data-v-4afc11f9="" class="pagination pagination"><!----><li data-v-5d3e9a75="" class="item current">1</li><li data-v-5d3e9a75="" class="item">2</li><li data-v-5d3e9a75="" class="item">下一页</li></ul></div><form data-v-4afc11f9="" class="reply-form"><textarea data-v-4afc11f9="" rows="1" maxlength="1024" placeholder="评论审核通过后显示" style="overflow: hidden; overflow-wrap: break-word; height: 35px;"></textarea><button data-v-4afc11f9="" class="reply-btn">评论</button></form></div></div></div><!----></div></li><li data-v-6adae277="" class="item"><div data-v-38783431="" data-v-6adae277="" class="comment"><div data-v-3a6943ce="" data-v-38783431="" st:block="userPopover" st:state="5a7512d3f265da4e8e7836b3" class="user-popover-box"><!----><a data-v-38783431="" href="https://juejin.im/user/5a7512d3f265da4e8e7836b3" target="_blank" rel="" data-v-3a6943ce=""><div data-v-57c47624="" data-v-cf310dfc="" data-v-38783431="" data-src="https://wx.qlogo.cn/mmopen/vi_32/DYAIOgq83eprK1NbO4HxZKo4OZ0jZ9ZY7vcEtAT1AmJhbibGCafV9HOBXrmqZ4Oj9R8PADCByw7DB6aFLOS7FmQ/132" class="lazy avatar avatar" style="background-image: none;"></div></a></div><div data-v-38783431="" class="content-box"><div data-v-38783431="" class="header"><div data-v-38783431="" class="user-info"><div data-v-3a6943ce="" data-v-38783431="" st:block="userPopover" st:state="5a7512d3f265da4e8e7836b3" class="user-popover-box"><!----><a data-v-38783431="" href="https://juejin.im/user/5a7512d3f265da4e8e7836b3" target="_blank" rel="" class="username" data-v-3a6943ce="">Murphy君</a></div><div data-v-38783431="" class="position"></div></div></div><div data-v-38783431="" class="content"><!----><span data-v-38783431="" class="content-html">通常在开发中我们不希望出现这样的问题，我们可以使用浅拷贝来解决这个情况。
这句话容易引起误解。
应该是我们可以使用深拷贝来解决这个情况。
或者是我们也可以使用以下浅拷贝来解决这个情况。</span><!----></div><div data-v-38783431="" class="footer"><button data-v-38783431="" class="like-btn"><i data-v-38783431="" class="collection-arrow-ion ion-arrow-up-b"></i><span data-v-38783431="">0</span></button><span data-v-38783431="" class="sub-comment-btn text-pointer"><span data-v-38783431="" class="title">收起评论</span><div data-v-38783431="" class="sub-comment--arrow" style=""></div></span><span data-v-38783431="" class="date">12天前</span><!----></div><div data-v-4afc11f9="" data-v-38783431="" class="sub-comment-box sub-comment-box"><div data-v-4afc11f9="" class="sub-comment-box__top"><div data-v-4afc11f9="" class="icon-close"></div><h3 data-v-4afc11f9="">评论</h3></div><div data-v-4afc11f9="" class="sub-comment-box__inner"><div data-v-4afc11f9=""><ul data-v-4afc11f9="" class="sub-comment-list"><li data-v-4afc11f9="" class="item"><div data-v-6fd44370="" data-v-4afc11f9="" class="sub-comment sub-comment"><div data-v-3a6943ce="" data-v-6fd44370="" st:block="userPopover" st:state="5885c542b123db16a33782fb" class="user-popover-box user-popover--avatar"><!----><div data-v-57c47624="" data-v-cf310dfc="" data-v-6fd44370="" data-src="https://b-gold-cdn.xitu.io/v3/static/img/default-avatar.e30559a.svg" class="lazy avatar avatar" data-v-3a6943ce="" style="background-image: none;"></div></div><div data-v-6fd44370="" class="content-box"><div data-v-6fd44370="" class="header"><div data-v-6fd44370="" class="user-info"><div data-v-3a6943ce="" data-v-6fd44370="" st:block="userPopover" st:state="5885c542b123db16a33782fb" class="user-popover-box user-popover--info"><!----><a data-v-6fd44370="" href="https://juejin.im/user/5885c542b123db16a33782fb" target="_blank" rel="" class="username" data-v-3a6943ce="">徐浪</a></div><div data-v-6fd44370="" class="position"></div></div></div><div data-v-6fd44370="" class="content"><!----><span data-v-6fd44370="" class="content-html">我看这段也懵了</span><!----></div><div data-v-6fd44370="" class="footer"><span data-v-6fd44370="" class="date">5天前</span><a data-v-6fd44370="" class="reply-btn">回复</a><!----></div></div><!----></div></li></ul><!----></div><form data-v-4afc11f9="" class="reply-form"><textarea data-v-4afc11f9="" rows="1" maxlength="1024" placeholder="评论审核通过后显示" style="overflow: hidden; overflow-wrap: break-word; height: 35px;"></textarea><button data-v-4afc11f9="" class="reply-btn">评论</button></form></div></div></div><!----></div></li><li data-v-6adae277="" class="item"><div data-v-38783431="" data-v-6adae277="" class="comment"><div data-v-3a6943ce="" data-v-38783431="" st:block="userPopover" st:state="5a9a9cdcf265da238b7d771c" class="user-popover-box"><!----><a data-v-38783431="" href="https://juejin.im/user/5a9a9cdcf265da238b7d771c" target="_blank" rel="" data-v-3a6943ce=""><div data-v-57c47624="" data-v-cf310dfc="" data-v-38783431="" data-src="https://user-gold-cdn.xitu.io/2018/5/18/163718f6169630b7?imageView2/1/w/100/h/100/q/85/format/webp/interlace/1" class="lazy avatar avatar" style="background-image: none;"></div></a></div><div data-v-38783431="" class="content-box"><div data-v-38783431="" class="header"><div data-v-38783431="" class="user-info"><div data-v-3a6943ce="" data-v-38783431="" st:block="userPopover" st:state="5a9a9cdcf265da238b7d771c" class="user-popover-box"><!----><a data-v-38783431="" href="https://juejin.im/user/5a9a9cdcf265da238b7d771c" target="_blank" rel="" class="username" data-v-3a6943ce="">浪里行舟</a></div><div data-v-38783431="" class="position">前端小白 @ 厦门</div></div></div><div data-v-38783431="" class="content"><!----><span data-v-38783431="" class="content-html">老师，对象赋值算浅拷贝？浅拷贝就是一级拷贝？深拷贝就是多级拷贝？Object.assign()可以理解如果是一级是深拷贝，多级是浅拷贝？望答复！</span><!----></div><div data-v-38783431="" class="footer"><button data-v-38783431="" class="like-btn"><i data-v-38783431="" class="collection-arrow-ion ion-arrow-up-b"></i><span data-v-38783431="">1</span></button><span data-v-38783431="" class="sub-comment-btn text-pointer"><span data-v-38783431="" class="title">收起评论</span><div data-v-38783431="" class="sub-comment--arrow" style=""></div></span><span data-v-38783431="" class="date">12天前</span><!----></div><div data-v-4afc11f9="" data-v-38783431="" class="sub-comment-box sub-comment-box"><div data-v-4afc11f9="" class="sub-comment-box__top"><div data-v-4afc11f9="" class="icon-close"></div><h3 data-v-4afc11f9="">评论</h3></div><div data-v-4afc11f9="" class="sub-comment-box__inner"><div data-v-4afc11f9=""><ul data-v-4afc11f9="" class="sub-comment-list"><li data-v-4afc11f9="" class="item"><div data-v-6fd44370="" data-v-4afc11f9="" class="sub-comment sub-comment"><div data-v-3a6943ce="" data-v-6fd44370="" st:block="userPopover" st:state="5a7512d3f265da4e8e7836b3" class="user-popover-box user-popover--avatar"><!----><div data-v-57c47624="" data-v-cf310dfc="" data-v-6fd44370="" data-src="https://wx.qlogo.cn/mmopen/vi_32/DYAIOgq83eprK1NbO4HxZKo4OZ0jZ9ZY7vcEtAT1AmJhbibGCafV9HOBXrmqZ4Oj9R8PADCByw7DB6aFLOS7FmQ/132" class="lazy avatar avatar" data-v-3a6943ce="" style="background-image: none;"></div></div><div data-v-6fd44370="" class="content-box"><div data-v-6fd44370="" class="header"><div data-v-6fd44370="" class="user-info"><div data-v-3a6943ce="" data-v-6fd44370="" st:block="userPopover" st:state="5a7512d3f265da4e8e7836b3" class="user-popover-box user-popover--info"><!----><a data-v-6fd44370="" href="https://juejin.im/user/5a7512d3f265da4e8e7836b3" target="_blank" rel="" class="username" data-v-3a6943ce="">Murphy君</a></div><div data-v-6fd44370="" class="position"></div></div></div><div data-v-6fd44370="" class="content"><!----><span data-v-6fd44370="" class="content-html">Object.assign()就是通过属性赋值的方式，一层时能达到深拷贝效果。你可以当他深拷贝了。嵌套对象就达不到深拷贝效果。那就是浅拷贝。</span><!----></div><div data-v-6fd44370="" class="footer"><span data-v-6fd44370="" class="date">12天前</span><a data-v-6fd44370="" class="reply-btn">回复</a><!----></div></div><!----></div></li><li data-v-4afc11f9="" class="item"><div data-v-6fd44370="" data-v-4afc11f9="" class="sub-comment sub-comment"><div data-v-3a6943ce="" data-v-6fd44370="" st:block="userPopover" st:state="593662c8ac502e0068beffea" class="user-popover-box user-popover--avatar"><!----><div data-v-57c47624="" data-v-cf310dfc="" data-v-6fd44370="" data-src="https://user-gold-cdn.xitu.io/2018/11/13/1670c0de2848b0fd?imageView2/1/w/100/h/100/q/85/format/webp/interlace/1" class="lazy avatar avatar" data-v-3a6943ce="" style="background-image: none;"></div></div><div data-v-6fd44370="" class="content-box"><div data-v-6fd44370="" class="header"><div data-v-6fd44370="" class="user-info"><div data-v-3a6943ce="" data-v-6fd44370="" st:block="userPopover" st:state="593662c8ac502e0068beffea" class="user-popover-box user-popover--info"><!----><a data-v-6fd44370="" href="https://juejin.im/user/593662c8ac502e0068beffea" target="_blank" rel="" class="username" data-v-3a6943ce="">这就是我的偶像</a></div><div data-v-6fd44370="" class="position">前端 @ 黑作坊</div></div></div><div data-v-6fd44370="" class="content"><!----><span data-v-6fd44370="" class="content-html">我感觉 深浅拷贝跟一级多级没关系吧，主要是因为有的会设计到引用类型，比如数组，对象。浅拷贝是没有把他们分开，修改其中一个会影响下一个。深拷贝的目的就是把彼此独立的两快内存，互不影响把  object.assign（）是浅拷贝 因为如果value是引用类型是会互相影响的。</span><!----></div><div data-v-6fd44370="" class="footer"><span data-v-6fd44370="" class="date">12天前</span><a data-v-6fd44370="" class="reply-btn">回复</a><!----></div></div><!----></div></li><li data-v-4afc11f9="" class="item"><div data-v-6fd44370="" data-v-4afc11f9="" class="sub-comment sub-comment"><div data-v-3a6943ce="" data-v-6fd44370="" st:block="userPopover" st:state="5a9a9cdcf265da238b7d771c" class="user-popover-box user-popover--avatar"><!----><div data-v-57c47624="" data-v-cf310dfc="" data-v-6fd44370="" data-src="https://user-gold-cdn.xitu.io/2018/5/18/163718f6169630b7?imageView2/1/w/100/h/100/q/85/format/webp/interlace/1" class="lazy avatar avatar" data-v-3a6943ce="" style="background-image: none;"></div></div><div data-v-6fd44370="" class="content-box"><div data-v-6fd44370="" class="header"><div data-v-6fd44370="" class="user-info"><div data-v-3a6943ce="" data-v-6fd44370="" st:block="userPopover" st:state="5a9a9cdcf265da238b7d771c" class="user-popover-box user-popover--info"><!----><a data-v-6fd44370="" href="https://juejin.im/user/5a9a9cdcf265da238b7d771c" target="_blank" rel="" class="username" data-v-3a6943ce="">浪里行舟</a></div><div data-v-6fd44370="" class="position">前端小白 @ 厦门</div></div></div><div data-v-6fd44370="" class="content"><span data-v-6fd44370="" class="text-reply">回复<a data-v-6fd44370="" href="https://juejin.im/user/5a7512d3f265da4e8e7836b3" target="_blank" rel=""><span data-v-6fd44370="" class="username">Murphy君</span></a>：</span><span data-v-6fd44370="" class="content-html">我也是这么理解的</span><!----></div><div data-v-6fd44370="" class="footer"><span data-v-6fd44370="" class="date">11天前</span><a data-v-6fd44370="" class="reply-btn">回复</a><!----></div></div><!----></div></li><li data-v-4afc11f9="" class="item"><div data-v-6fd44370="" data-v-4afc11f9="" class="sub-comment sub-comment"><div data-v-3a6943ce="" data-v-6fd44370="" st:block="userPopover" st:state="5b3c63d3e51d45190570a857" class="user-popover-box user-popover--avatar"><!----><div data-v-57c47624="" data-v-cf310dfc="" data-v-6fd44370="" data-src="https://user-gold-cdn.xitu.io/2019/1/4/16816913f99a8dc9?imageView2/1/w/100/h/100/q/85/format/webp/interlace/1" class="lazy avatar avatar" data-v-3a6943ce="" style="background-image: none;"></div></div><div data-v-6fd44370="" class="content-box"><div data-v-6fd44370="" class="header"><div data-v-6fd44370="" class="user-info"><div data-v-3a6943ce="" data-v-6fd44370="" st:block="userPopover" st:state="5b3c63d3e51d45190570a857" class="user-popover-box user-popover--info"><!----><a data-v-6fd44370="" href="https://juejin.im/user/5b3c63d3e51d45190570a857" target="_blank" rel="" class="username" data-v-3a6943ce="">彩虹之心</a></div><div data-v-6fd44370="" class="position">前端菜鸡 @ Quantex</div></div></div><div data-v-6fd44370="" class="content"><!----><span data-v-6fd44370="" class="content-html">深复制和浅复制最根本的区别在于是否是真正获取了一个对象的复制实体，而不是引用，
1）深复制在计算机中开辟了一块内存地址用于存放复制的对象，
2）而浅复制仅仅是指向被复制的内存地址，如果原地址中对象被改变了，那么浅复制出来的对象也会相应改变。</span><!----></div><div data-v-6fd44370="" class="footer"><span data-v-6fd44370="" class="date">2天前</span><a data-v-6fd44370="" class="reply-btn">回复</a><!----></div></div><!----></div></li><li data-v-4afc11f9="" class="item"><div data-v-6fd44370="" data-v-4afc11f9="" class="sub-comment sub-comment"><div data-v-3a6943ce="" data-v-6fd44370="" st:block="userPopover" st:state="5a24ec496fb9a0450d10e8c4" class="user-popover-box user-popover--avatar"><!----><div data-v-57c47624="" data-v-cf310dfc="" data-v-6fd44370="" data-src="https://wx.qlogo.cn/mmopen/vi_32/Q0j4TwGTfTLFeoKYXPtib8ZW6vmccnCL3uesNMxs2qF6xUed5acFow2TpLEval00EOxqpqbEcQ8zX9J7BdtDicCA/0" class="lazy avatar avatar" data-v-3a6943ce="" style="background-image: none;"></div></div><div data-v-6fd44370="" class="content-box"><div data-v-6fd44370="" class="header"><div data-v-6fd44370="" class="user-info"><div data-v-3a6943ce="" data-v-6fd44370="" st:block="userPopover" st:state="5a24ec496fb9a0450d10e8c4" class="user-popover-box user-popover--info"><!----><a data-v-6fd44370="" href="https://juejin.im/user/5a24ec496fb9a0450d10e8c4" target="_blank" rel="" class="username" data-v-3a6943ce="">fitcong</a></div><div data-v-6fd44370="" class="position">前端 @ 怕丢公司人</div></div></div><div data-v-6fd44370="" class="content"><!----><span data-v-6fd44370="" class="content-html">我的理解:所谓的深拷贝就是重新创建所有引用类型的内存地址,将其重新赋值,浅拷贝只是改变顶层或者某几层的内存地址</span><!----></div><div data-v-6fd44370="" class="footer"><span data-v-6fd44370="" class="date">6小时前</span><a data-v-6fd44370="" class="reply-btn">回复</a><!----></div></div><!----></div></li></ul><!----></div><form data-v-4afc11f9="" class="reply-form"><textarea data-v-4afc11f9="" rows="1" maxlength="1024" placeholder="评论审核通过后显示" style="overflow: hidden; overflow-wrap: break-word; height: 35px;"></textarea><button data-v-4afc11f9="" class="reply-btn">评论</button></form></div></div></div><!----></div></li><li data-v-6adae277="" class="item"><div data-v-38783431="" data-v-6adae277="" class="comment"><div data-v-3a6943ce="" data-v-38783431="" st:block="userPopover" st:state="5b47eac6e51d4519115ced21" class="user-popover-box"><!----><a data-v-38783431="" href="https://juejin.im/user/5b47eac6e51d4519115ced21" target="_blank" rel="" data-v-3a6943ce=""><div data-v-57c47624="" data-v-cf310dfc="" data-v-38783431="" data-src="https://thirdwx.qlogo.cn/mmopen/vi_32/hbMNmZsdV4icq8IHoYduBfN9V8icnjs936a9voR994EsXicaGeqiaRobgpW3XA0qfvhic1Izudp7NbqxSH4S9iaR9DHQ/132" class="lazy avatar avatar" style="background-image: none;"></div></a></div><div data-v-38783431="" class="content-box"><div data-v-38783431="" class="header"><div data-v-38783431="" class="user-info"><div data-v-3a6943ce="" data-v-38783431="" st:block="userPopover" st:state="5b47eac6e51d4519115ced21" class="user-popover-box"><!----><a data-v-38783431="" href="https://juejin.im/user/5b47eac6e51d4519115ced21" target="_blank" rel="" class="username" data-v-3a6943ce="">MRHE</a></div><div data-v-38783431="" class="position">小白 @ 未入职</div></div></div><div data-v-38783431="" class="content"><!----><span data-v-38783431="" class="content-html collapsed">deepClone

function deepClone (origin , target ) {
	var target = target || {};
	toStr = Object.prototype.toString;
	arrStr ='[object Array]' ;
	for(var prop in origin){
		if(origin.hasOwnProperty(prop)){
			if(origin[prop]!== "null"&amp;&amp;typeof(origin[prop]) == 'object'){…</span><span data-v-38783431="" class="show-all">展开全部</span></div><div data-v-38783431="" class="footer"><button data-v-38783431="" class="like-btn"><i data-v-38783431="" class="collection-arrow-ion ion-arrow-up-b"></i><span data-v-38783431="">4</span></button><span data-v-38783431="" class="sub-comment-btn text-pointer"><span data-v-38783431="" class="title">评论</span><div data-v-38783431="" class="sub-comment--arrow" style="display: none;"></div></span><span data-v-38783431="" class="date">13天前</span><!----></div><!----></div><!----></div></li><li data-v-6adae277="" class="item"><div data-v-38783431="" data-v-6adae277="" class="comment"><div data-v-3a6943ce="" data-v-38783431="" st:block="userPopover" st:state="5b2a869bf265da598451f086" class="user-popover-box"><!----><a data-v-38783431="" href="https://juejin.im/user/5b2a869bf265da598451f086" target="_blank" rel="" data-v-3a6943ce=""><div data-v-57c47624="" data-v-cf310dfc="" data-v-38783431="" data-src="https://thirdwx.qlogo.cn/mmopen/vi_32/Q0j4TwGTfTJlOd9jpb1AbRfOF8LqBNBGkJqp5f9QeFQAzl5PNtcQaq835NsVRPBPGwpL8Nk0o21JicPUfc3cAicQ/132" class="lazy avatar avatar" style="background-image: none;"></div></a></div><div data-v-38783431="" class="content-box"><div data-v-38783431="" class="header"><div data-v-38783431="" class="user-info"><div data-v-3a6943ce="" data-v-38783431="" st:block="userPopover" st:state="5b2a869bf265da598451f086" class="user-popover-box"><!----><a data-v-38783431="" href="https://juejin.im/user/5b2a869bf265da598451f086" target="_blank" rel="" class="username" data-v-3a6943ce="">沈小扬🏃🎸</a></div><div data-v-38783431="" class="position">全栈工程师 @ 彼此服务工坊</div></div></div><div data-v-38783431="" class="content"><!----><span data-v-38783431="" class="content-html">js原型和原型链的原理之后，有什么应用场景呢？</span><!----></div><div data-v-38783431="" class="footer"><button data-v-38783431="" class="like-btn"><i data-v-38783431="" class="collection-arrow-ion ion-arrow-up-b"></i><span data-v-38783431="">0</span></button><span data-v-38783431="" class="sub-comment-btn text-pointer"><span data-v-38783431="" class="title">收起评论</span><div data-v-38783431="" class="sub-comment--arrow" style=""></div></span><span data-v-38783431="" class="date">14天前</span><!----></div><div data-v-4afc11f9="" data-v-38783431="" class="sub-comment-box sub-comment-box"><div data-v-4afc11f9="" class="sub-comment-box__top"><div data-v-4afc11f9="" class="icon-close"></div><h3 data-v-4afc11f9="">评论</h3></div><div data-v-4afc11f9="" class="sub-comment-box__inner"><div data-v-4afc11f9=""><ul data-v-4afc11f9="" class="sub-comment-list"><li data-v-4afc11f9="" class="item"><div data-v-6fd44370="" data-v-4afc11f9="" class="sub-comment sub-comment"><div data-v-3a6943ce="" data-v-6fd44370="" st:block="userPopover" st:state="58b096f1128fe1006cbcbf77" class="user-popover-box user-popover--avatar"><!----><div data-v-57c47624="" data-v-cf310dfc="" data-v-6fd44370="" data-src="https://leancloud-gold-cdn.xitu.io/bebe2b39d10785e9bac6.JPG?imageView2/1/w/100/h/100/q/85/format/webp/interlace/1" class="lazy avatar avatar" data-v-3a6943ce="" style="background-image: none;"></div></div><div data-v-6fd44370="" class="content-box"><div data-v-6fd44370="" class="header"><div data-v-6fd44370="" class="user-info"><div data-v-3a6943ce="" data-v-6fd44370="" st:block="userPopover" st:state="58b096f1128fe1006cbcbf77" class="user-popover-box user-popover--info"><!----><a data-v-6fd44370="" href="https://juejin.im/user/58b096f1128fe1006cbcbf77" target="_blank" rel="" class="username" data-v-3a6943ce="">杨鑫丶</a></div><div data-v-6fd44370="" class="position">Android攻城狮，前端爱好者</div></div></div><div data-v-6fd44370="" class="content"><!----><span data-v-6fd44370="" class="content-html">实现类高级语言的继承特性，ES6的class本质就是使用原型链继承实现的</span><!----></div><div data-v-6fd44370="" class="footer"><span data-v-6fd44370="" class="date">14天前</span><a data-v-6fd44370="" class="reply-btn">回复</a><!----></div></div><!----></div></li></ul><!----></div><form data-v-4afc11f9="" class="reply-form"><textarea data-v-4afc11f9="" rows="1" maxlength="1024" placeholder="评论审核通过后显示" style="overflow: hidden; overflow-wrap: break-word; height: 35px;"></textarea><button data-v-4afc11f9="" class="reply-btn">评论</button></form></div></div></div><!----></div></li><li data-v-6adae277="" class="item"><div data-v-38783431="" data-v-6adae277="" class="comment"><div data-v-3a6943ce="" data-v-38783431="" st:block="userPopover" st:state="594bfe276fb9a06bb0190830" class="user-popover-box"><!----><a data-v-38783431="" href="https://juejin.im/user/594bfe276fb9a06bb0190830" target="_blank" rel="" data-v-3a6943ce=""><div data-v-57c47624="" data-v-cf310dfc="" data-v-38783431="" data-src="https://tva1.sinaimg.cn/crop.0.0.968.968.180/415e979djw8enzen3xsiwj20qw0qxdip.jpg" class="lazy avatar avatar" style="background-image: none;"></div></a></div><div data-v-38783431="" class="content-box"><div data-v-38783431="" class="header"><div data-v-38783431="" class="user-info"><div data-v-3a6943ce="" data-v-38783431="" st:block="userPopover" st:state="594bfe276fb9a06bb0190830" class="user-popover-box"><!----><a data-v-38783431="" href="https://juejin.im/user/594bfe276fb9a06bb0190830" target="_blank" rel="" class="username" data-v-3a6943ce="">陈恩培EChen</a></div><div data-v-38783431="" class="position">前端开发工程师 @ 美图公司</div></div></div><div data-v-38783431="" class="content"><!----><span data-v-38783431="" class="content-html collapsed">你好，文章末尾对原型链的阐述让我有些困惑。

按我的理解，文章里的说法是指：一个构造函数生成了多个实例，这些实例因为有共同的指针（即 _proto_）指向原型对象，所以实例与原型间形成了原型链。

然而《高程（第 3 版）》里对原型链的阐述是：
「假如如我们让原型对象等于另一个类型的实例，此时原型对象将包含一个指向另一个原型的指针，相应地，另一个原型中也包含着一个指向另一个构造函数的指针。如另一个原型又是另一个类型的实例，那么上述关系依然成立，如此层层递进，就构成了实例与原型的链条。这就是原型链的基本概念。」…</span><span data-v-38783431="" class="show-all">展开全部</span></div><div data-v-38783431="" class="footer"><button data-v-38783431="" class="like-btn"><i data-v-38783431="" class="collection-arrow-ion ion-arrow-up-b"></i><span data-v-38783431="">0</span></button><span data-v-38783431="" class="sub-comment-btn text-pointer"><span data-v-38783431="" class="title">收起评论</span><div data-v-38783431="" class="sub-comment--arrow" style=""></div></span><span data-v-38783431="" class="date">14天前</span><!----></div><div data-v-4afc11f9="" data-v-38783431="" class="sub-comment-box sub-comment-box"><div data-v-4afc11f9="" class="sub-comment-box__top"><div data-v-4afc11f9="" class="icon-close"></div><h3 data-v-4afc11f9="">评论</h3></div><div data-v-4afc11f9="" class="sub-comment-box__inner"><div data-v-4afc11f9=""><ul data-v-4afc11f9="" class="sub-comment-list"><li data-v-4afc11f9="" class="item"><div data-v-6fd44370="" data-v-4afc11f9="" class="sub-comment sub-comment"><div data-v-3a6943ce="" data-v-6fd44370="" st:block="userPopover" st:state="574f8d8d2e958a005fd4edac" class="user-popover-box user-popover--avatar"><!----><div data-v-57c47624="" data-v-cf310dfc="" data-v-6fd44370="" data-src="https://user-gold-cdn.xitu.io/2018/10/30/166c3fd3666b5d05?imageView2/1/w/100/h/100/q/85/format/webp/interlace/1" class="lazy avatar avatar loaded" data-v-3a6943ce="" style="background-image: url(&quot;https://user-gold-cdn.xitu.io/2018/10/30/166c3fd3666b5d05?imageView2/1/w/100/h/100/q/85/format/webp/interlace/1&quot;);"></div></div><div data-v-6fd44370="" class="content-box"><div data-v-6fd44370="" class="header"><div data-v-6fd44370="" class="user-info"><div data-v-3a6943ce="" data-v-6fd44370="" st:block="userPopover" st:state="574f8d8d2e958a005fd4edac" class="user-popover-box user-popover--info"><!----><a data-v-6fd44370="" href="https://juejin.im/user/574f8d8d2e958a005fd4edac" target="_blank" rel="" class="username" data-v-3a6943ce="">yck</a></div><div data-v-6fd44370="" class="position"></div></div></div><div data-v-6fd44370="" class="content"><!----><span data-v-6fd44370="" class="content-html">我认为原型链很简单，就是多个对象通过 _proto_ 连接起来，不论是引擎自动实现的还是我们手动的。另外说实话，高程的这个阐述过于晦涩。。。</span><!----></div><div data-v-6fd44370="" class="footer"><span data-v-6fd44370="" class="date">14天前</span><a data-v-6fd44370="" class="reply-btn">回复</a><!----></div></div><!----></div></li><li data-v-4afc11f9="" class="item"><div data-v-6fd44370="" data-v-4afc11f9="" class="sub-comment sub-comment"><div data-v-3a6943ce="" data-v-6fd44370="" st:block="userPopover" st:state="594bfe276fb9a06bb0190830" class="user-popover-box user-popover--avatar"><!----><div data-v-57c47624="" data-v-cf310dfc="" data-v-6fd44370="" data-src="https://tva1.sinaimg.cn/crop.0.0.968.968.180/415e979djw8enzen3xsiwj20qw0qxdip.jpg" class="lazy avatar avatar" data-v-3a6943ce="" style="background-image: none;"></div></div><div data-v-6fd44370="" class="content-box"><div data-v-6fd44370="" class="header"><div data-v-6fd44370="" class="user-info"><div data-v-3a6943ce="" data-v-6fd44370="" st:block="userPopover" st:state="594bfe276fb9a06bb0190830" class="user-popover-box user-popover--info"><!----><a data-v-6fd44370="" href="https://juejin.im/user/594bfe276fb9a06bb0190830" target="_blank" rel="" class="username" data-v-3a6943ce="">陈恩培EChen</a></div><div data-v-6fd44370="" class="position">前端开发工程师 @ 美图公司</div></div></div><div data-v-6fd44370="" class="content"><span data-v-6fd44370="" class="text-reply">回复<a data-v-6fd44370="" href="https://juejin.im/user/574f8d8d2e958a005fd4edac" target="_blank" rel=""><span data-v-6fd44370="" class="username">yck</span></a>：</span><span data-v-6fd44370="" class="content-html">我明白你的意思了，你指的「多个对象」是分属于不同类型的，他们之间通过  _proto_ 连接，所以包含彼此的属性和方法。我之前读的时候还以为你指的「多个对象」从属于同一个类型，看来是我理解错了。
不过我还是建议补充下原型链的实现，即「一个类型的原型对象等于另一个类型的实例」，伪代码大概是 Subtype.prototype = new SuperType()。我认为它有助于阐述这种继承关系。</span><!----></div><div data-v-6fd44370="" class="footer"><span data-v-6fd44370="" class="date">14天前</span><a data-v-6fd44370="" class="reply-btn">回复</a><!----></div></div><!----></div></li></ul><!----></div><form data-v-4afc11f9="" class="reply-form"><textarea data-v-4afc11f9="" rows="1" maxlength="1024" placeholder="评论审核通过后显示" style="overflow: hidden; overflow-wrap: break-word; height: 35px;"></textarea><button data-v-4afc11f9="" class="reply-btn">评论</button></form></div></div></div><!----></div></li><li data-v-6adae277="" class="item"><div data-v-38783431="" data-v-6adae277="" class="comment"><div data-v-3a6943ce="" data-v-38783431="" st:block="userPopover" st:state="583fe3792f301e005cf59928" class="user-popover-box"><!----><a data-v-38783431="" href="https://juejin.im/user/583fe3792f301e005cf59928" target="_blank" rel="" data-v-3a6943ce=""><div data-v-57c47624="" data-v-cf310dfc="" data-v-38783431="" data-src="https://avatars.githubusercontent.com/u/16032240?v=3" class="lazy avatar avatar" style="background-image: none;"></div></a></div><div data-v-38783431="" class="content-box"><div data-v-38783431="" class="header"><div data-v-38783431="" class="user-info"><div data-v-3a6943ce="" data-v-38783431="" st:block="userPopover" st:state="583fe3792f301e005cf59928" class="user-popover-box"><!----><a data-v-38783431="" href="https://juejin.im/user/583fe3792f301e005cf59928" target="_blank" rel="" class="username" data-v-3a6943ce="">莫痕</a></div><div data-v-38783431="" class="position">前端打杂工程师</div></div></div><div data-v-38783431="" class="content"><!----><span data-v-38783431="" class="content-html">deepClone 函数在对函数的处理上有问题。走 `let newObj = isArray ? [...obj] : { ...obj }` 语句时会被转换成 {}。</span><!----></div><div data-v-38783431="" class="footer"><button data-v-38783431="" class="like-btn"><i data-v-38783431="" class="collection-arrow-ion ion-arrow-up-b"></i><span data-v-38783431="">0</span></button><span data-v-38783431="" class="sub-comment-btn text-pointer"><span data-v-38783431="" class="title">收起评论</span><div data-v-38783431="" class="sub-comment--arrow" style=""></div></span><span data-v-38783431="" class="date">17天前</span><!----></div><div data-v-4afc11f9="" data-v-38783431="" class="sub-comment-box sub-comment-box"><div data-v-4afc11f9="" class="sub-comment-box__top"><div data-v-4afc11f9="" class="icon-close"></div><h3 data-v-4afc11f9="">评论</h3></div><div data-v-4afc11f9="" class="sub-comment-box__inner"><div data-v-4afc11f9=""><ul data-v-4afc11f9="" class="sub-comment-list"><li data-v-4afc11f9="" class="item"><div data-v-6fd44370="" data-v-4afc11f9="" class="sub-comment sub-comment"><div data-v-3a6943ce="" data-v-6fd44370="" st:block="userPopover" st:state="574f8d8d2e958a005fd4edac" class="user-popover-box user-popover--avatar"><!----><div data-v-57c47624="" data-v-cf310dfc="" data-v-6fd44370="" data-src="https://user-gold-cdn.xitu.io/2018/10/30/166c3fd3666b5d05?imageView2/1/w/100/h/100/q/85/format/webp/interlace/1" class="lazy avatar avatar loaded" data-v-3a6943ce="" style="background-image: url(&quot;https://user-gold-cdn.xitu.io/2018/10/30/166c3fd3666b5d05?imageView2/1/w/100/h/100/q/85/format/webp/interlace/1&quot;);"></div></div><div data-v-6fd44370="" class="content-box"><div data-v-6fd44370="" class="header"><div data-v-6fd44370="" class="user-info"><div data-v-3a6943ce="" data-v-6fd44370="" st:block="userPopover" st:state="574f8d8d2e958a005fd4edac" class="user-popover-box user-popover--info"><!----><a data-v-6fd44370="" href="https://juejin.im/user/574f8d8d2e958a005fd4edac" target="_blank" rel="" class="username" data-v-3a6943ce="">yck</a></div><div data-v-6fd44370="" class="position"></div></div></div><div data-v-6fd44370="" class="content"><!----><span data-v-6fd44370="" class="content-html">简易实现 不考虑这些边界问题 只是一个思路</span><!----></div><div data-v-6fd44370="" class="footer"><span data-v-6fd44370="" class="date">17天前</span><a data-v-6fd44370="" class="reply-btn">回复</a><!----></div></div><!----></div></li></ul><!----></div><form data-v-4afc11f9="" class="reply-form"><textarea data-v-4afc11f9="" rows="1" maxlength="1024" placeholder="评论审核通过后显示" style="overflow: hidden; overflow-wrap: break-word; height: 35px;"></textarea><button data-v-4afc11f9="" class="reply-btn">评论</button></form></div></div></div><!----></div></li><li data-v-6adae277="" class="item"><div data-v-38783431="" data-v-6adae277="" class="comment"><div data-v-3a6943ce="" data-v-38783431="" st:block="userPopover" st:state="5a41fbb06fb9a0452a3c9497" class="user-popover-box"><!----><a data-v-38783431="" href="https://juejin.im/user/5a41fbb06fb9a0452a3c9497" target="_blank" rel="" data-v-3a6943ce=""><div data-v-57c47624="" data-v-cf310dfc="" data-v-38783431="" data-src="https://user-gold-cdn.xitu.io/2018/12/21/167ce96a879025e0?imageView2/1/w/100/h/100/q/85/format/webp/interlace/1" class="lazy avatar avatar" style="background-image: none;"></div></a></div><div data-v-38783431="" class="content-box"><div data-v-38783431="" class="header"><div data-v-38783431="" class="user-info"><div data-v-3a6943ce="" data-v-38783431="" st:block="userPopover" st:state="5a41fbb06fb9a0452a3c9497" class="user-popover-box"><!----><a data-v-38783431="" href="https://juejin.im/user/5a41fbb06fb9a0452a3c9497" target="_blank" rel="" class="username" data-v-3a6943ce="">juejin_zsn</a></div><div data-v-38783431="" class="position">前端小白白</div></div></div><div data-v-38783431="" class="content"><!----><span data-v-38783431="" class="content-html">console.log([] == ![]) //true
// 解析：
console.log(![]) // false  一边为boolean,将Boolean转为Number
console.log(Number(![])) // 0
console.log([] == 0) //true
console.log([] == ![]) //true
是这样吗？</span><!----></div><div data-v-38783431="" class="footer"><button data-v-38783431="" class="like-btn"><i data-v-38783431="" class="collection-arrow-ion ion-arrow-up-b"></i><span data-v-38783431="">0</span></button><span data-v-38783431="" class="sub-comment-btn text-pointer"><span data-v-38783431="" class="title">收起评论</span><div data-v-38783431="" class="sub-comment--arrow" style=""></div></span><span data-v-38783431="" class="date">20天前</span><!----></div><div data-v-4afc11f9="" data-v-38783431="" class="sub-comment-box sub-comment-box"><div data-v-4afc11f9="" class="sub-comment-box__top"><div data-v-4afc11f9="" class="icon-close"></div><h3 data-v-4afc11f9="">评论</h3></div><div data-v-4afc11f9="" class="sub-comment-box__inner"><div data-v-4afc11f9=""><ul data-v-4afc11f9="" class="sub-comment-list"><li data-v-4afc11f9="" class="item"><div data-v-6fd44370="" data-v-4afc11f9="" class="sub-comment sub-comment"><div data-v-3a6943ce="" data-v-6fd44370="" st:block="userPopover" st:state="595a4dbef265da6c2a7475e3" class="user-popover-box user-popover--avatar"><!----><div data-v-57c47624="" data-v-cf310dfc="" data-v-6fd44370="" data-src="https://leancloud-gold-cdn.xitu.io/dN9kHxMdO1oVqB75LHkzQ0A?imageView2/1/w/100/h/100/q/85/format/webp/interlace/1" class="lazy avatar avatar" data-v-3a6943ce="" style="background-image: none;"></div></div><div data-v-6fd44370="" class="content-box"><div data-v-6fd44370="" class="header"><div data-v-6fd44370="" class="user-info"><div data-v-3a6943ce="" data-v-6fd44370="" st:block="userPopover" st:state="595a4dbef265da6c2a7475e3" class="user-popover-box user-popover--info"><!----><a data-v-6fd44370="" href="https://juejin.im/user/595a4dbef265da6c2a7475e3" target="_blank" rel="" class="username" data-v-3a6943ce="">cyh41</a></div><div data-v-6fd44370="" class="position">前端工程师</div></div></div><div data-v-6fd44370="" class="content"><!----><span data-v-6fd44370="" class="content-html collapsed">右边：
        ![]: []为true so ![]为false
        即 [] == false;
        当一边为Boolean 则将Boolean转换为Number 即 false 为 0;
        即 [] == 0;
左边：
        当一边为对象，则调用对象的valueOf()方法转换 [].valueOf() 为 []；
        因为还不是原始值则调用toString()： [].toStrin…</span><span data-v-6fd44370="" class="show-all">展开全部</span></div><div data-v-6fd44370="" class="footer"><span data-v-6fd44370="" class="date">18天前</span><a data-v-6fd44370="" class="reply-btn">回复</a><!----></div></div><!----></div></li><li data-v-4afc11f9="" class="item"><div data-v-6fd44370="" data-v-4afc11f9="" class="sub-comment sub-comment"><div data-v-3a6943ce="" data-v-6fd44370="" st:block="userPopover" st:state="59f167e7f265da430d573cb9" class="user-popover-box user-popover--avatar"><!----><div data-v-57c47624="" data-v-cf310dfc="" data-v-6fd44370="" data-src="https://user-gold-cdn.xitu.io/2017/10/26/2c159b7e2fc6994a8512a1423a0ebb51?imageView2/1/w/100/h/100/q/85/format/webp/interlace/1" class="lazy avatar avatar" data-v-3a6943ce="" style="background-image: none;"></div></div><div data-v-6fd44370="" class="content-box"><div data-v-6fd44370="" class="header"><div data-v-6fd44370="" class="user-info"><div data-v-3a6943ce="" data-v-6fd44370="" st:block="userPopover" st:state="59f167e7f265da430d573cb9" class="user-popover-box user-popover--info"><!----><a data-v-6fd44370="" href="https://juejin.im/user/59f167e7f265da430d573cb9" target="_blank" rel="" class="username" data-v-3a6943ce="">大肉排小新</a></div><div data-v-6fd44370="" class="position">前端攻城狮</div></div></div><div data-v-6fd44370="" class="content"><span data-v-6fd44370="" class="text-reply">回复<a data-v-6fd44370="" href="https://juejin.im/user/595a4dbef265da6c2a7475e3" target="_blank" rel=""><span data-v-6fd44370="" class="username">cyh41</span></a>：</span><span data-v-6fd44370="" class="content-html">解释到位</span><!----></div><div data-v-6fd44370="" class="footer"><span data-v-6fd44370="" class="date">11天前</span><a data-v-6fd44370="" class="reply-btn">回复</a><!----></div></div><!----></div></li><li data-v-4afc11f9="" class="item"><div data-v-6fd44370="" data-v-4afc11f9="" class="sub-comment sub-comment"><div data-v-3a6943ce="" data-v-6fd44370="" st:block="userPopover" st:state="5adf202af265da0b84551306" class="user-popover-box user-popover--avatar"><!----><div data-v-57c47624="" data-v-cf310dfc="" data-v-6fd44370="" data-src="https://user-gold-cdn.xitu.io/2019/1/8/1682cdf36e80f675?imageView2/1/w/100/h/100/q/85/format/webp/interlace/1" class="lazy avatar avatar loaded" data-v-3a6943ce="" style="background-image: url(&quot;https://user-gold-cdn.xitu.io/2019/1/8/1682cdf36e80f675?imageView2/1/w/100/h/100/q/85/format/webp/interlace/1&quot;);"></div></div><div data-v-6fd44370="" class="content-box"><div data-v-6fd44370="" class="header"><div data-v-6fd44370="" class="user-info"><div data-v-3a6943ce="" data-v-6fd44370="" st:block="userPopover" st:state="5adf202af265da0b84551306" class="user-popover-box user-popover--info"><!----><a data-v-6fd44370="" href="https://juejin.im/user/5adf202af265da0b84551306" target="_blank" rel="" class="username" data-v-3a6943ce="">wq93</a></div><div data-v-6fd44370="" class="position">前端工程师</div></div></div><div data-v-6fd44370="" class="content"><!----><span data-v-6fd44370="" class="content-html">这个分析满分!</span><!----></div><div data-v-6fd44370="" class="footer"><span data-v-6fd44370="" class="date">6天前</span><a data-v-6fd44370="" class="reply-btn">回复</a><!----></div></div><!----></div></li></ul><!----></div><form data-v-4afc11f9="" class="reply-form"><textarea data-v-4afc11f9="" rows="1" maxlength="1024" placeholder="评论审核通过后显示" style="overflow: hidden; overflow-wrap: break-word; height: 35px;"></textarea><button data-v-4afc11f9="" class="reply-btn">评论</button></form></div></div></div><!----></div></li><li data-v-6adae277="" class="item"><div data-v-38783431="" data-v-6adae277="" class="comment"><div data-v-3a6943ce="" data-v-38783431="" st:block="userPopover" st:state="5b847cd2e51d4538af60f8cd" class="user-popover-box"><!----><a data-v-38783431="" href="https://juejin.im/user/5b847cd2e51d4538af60f8cd" target="_blank" rel="" data-v-3a6943ce=""><div data-v-57c47624="" data-v-cf310dfc="" data-v-38783431="" data-src="https://user-gold-cdn.xitu.io/2018/12/4/16778e36153f2e5b?imageView2/1/w/100/h/100/q/85/format/webp/interlace/1" class="lazy avatar avatar" style="background-image: none;"></div></a></div><div data-v-38783431="" class="content-box"><div data-v-38783431="" class="header"><div data-v-38783431="" class="user-info"><div data-v-3a6943ce="" data-v-38783431="" st:block="userPopover" st:state="5b847cd2e51d4538af60f8cd" class="user-popover-box"><!----><a data-v-38783431="" href="https://juejin.im/user/5b847cd2e51d4538af60f8cd" target="_blank" rel="" class="username" data-v-3a6943ce="">RedHoyse</a></div><div data-v-38783431="" class="position">前端工程师</div></div></div><div data-v-38783431="" class="content"><!----><span data-v-38783431="" class="content-html">原型爸爸那张图可以说很爸爸了😏</span><!----></div><div data-v-38783431="" class="footer"><button data-v-38783431="" class="like-btn"><i data-v-38783431="" class="collection-arrow-ion ion-arrow-up-b"></i><span data-v-38783431="">0</span></button><span data-v-38783431="" class="sub-comment-btn text-pointer"><span data-v-38783431="" class="title">评论</span><div data-v-38783431="" class="sub-comment--arrow" style="display: none;"></div></span><span data-v-38783431="" class="date">29天前</span><!----></div><!----></div><!----></div></li><li data-v-6adae277="" class="item"><div data-v-38783431="" data-v-6adae277="" class="comment"><div data-v-3a6943ce="" data-v-38783431="" st:block="userPopover" st:state="5bee78d0e51d452ade4fb053" class="user-popover-box"><!----><a data-v-38783431="" href="https://juejin.im/user/5bee78d0e51d452ade4fb053" target="_blank" rel="" data-v-3a6943ce=""><div data-v-57c47624="" data-v-cf310dfc="" data-v-38783431="" data-src="https://avatars2.githubusercontent.com/u/33317030?v=4" class="lazy avatar avatar" style="background-image: none;"></div></a></div><div data-v-38783431="" class="content-box"><div data-v-38783431="" class="header"><div data-v-38783431="" class="user-info"><div data-v-3a6943ce="" data-v-38783431="" st:block="userPopover" st:state="5bee78d0e51d452ade4fb053" class="user-popover-box"><!----><a data-v-38783431="" href="https://juejin.im/user/5bee78d0e51d452ade4fb053" target="_blank" rel="" class="username" data-v-3a6943ce="">zhaofeihao</a></div><div data-v-38783431="" class="position">前端 @ caiji</div></div></div><div data-v-38783431="" class="content"><!----><span data-v-38783431="" class="content-html collapsed">var obj = {
  a: 1,
  b: {
    c: obj.b
  }
}(
  // 注意该方法是异步的
  // 可以处理 undefined 和循环引用对象
  async () =&gt; {
    const clone = await structuralClone(o…</span><span data-v-38783431="" class="show-all">展开全部</span></div><div data-v-38783431="" class="footer"><button data-v-38783431="" class="like-btn"><i data-v-38783431="" class="collection-arrow-ion ion-arrow-up-b"></i><span data-v-38783431="">0</span></button><span data-v-38783431="" class="sub-comment-btn text-pointer"><span data-v-38783431="" class="title">收起评论</span><div data-v-38783431="" class="sub-comment--arrow" style=""></div></span><span data-v-38783431="" class="date">1月前</span><!----></div><div data-v-4afc11f9="" data-v-38783431="" class="sub-comment-box sub-comment-box"><div data-v-4afc11f9="" class="sub-comment-box__top"><div data-v-4afc11f9="" class="icon-close"></div><h3 data-v-4afc11f9="">评论</h3></div><div data-v-4afc11f9="" class="sub-comment-box__inner"><div data-v-4afc11f9=""><ul data-v-4afc11f9="" class="sub-comment-list"><li data-v-4afc11f9="" class="item"><div data-v-6fd44370="" data-v-4afc11f9="" class="sub-comment sub-comment"><div data-v-3a6943ce="" data-v-6fd44370="" st:block="userPopover" st:state="574f8d8d2e958a005fd4edac" class="user-popover-box user-popover--avatar"><!----><div data-v-57c47624="" data-v-cf310dfc="" data-v-6fd44370="" data-src="https://user-gold-cdn.xitu.io/2018/10/30/166c3fd3666b5d05?imageView2/1/w/100/h/100/q/85/format/webp/interlace/1" class="lazy avatar avatar loaded" data-v-3a6943ce="" style="background-image: url(&quot;https://user-gold-cdn.xitu.io/2018/10/30/166c3fd3666b5d05?imageView2/1/w/100/h/100/q/85/format/webp/interlace/1&quot;);"></div></div><div data-v-6fd44370="" class="content-box"><div data-v-6fd44370="" class="header"><div data-v-6fd44370="" class="user-info"><div data-v-3a6943ce="" data-v-6fd44370="" st:block="userPopover" st:state="574f8d8d2e958a005fd4edac" class="user-popover-box user-popover--info"><!----><a data-v-6fd44370="" href="https://juejin.im/user/574f8d8d2e958a005fd4edac" target="_blank" rel="" class="username" data-v-3a6943ce="">yck</a></div><div data-v-6fd44370="" class="position"></div></div></div><div data-v-6fd44370="" class="content"><!----><span data-v-6fd44370="" class="content-html">尝试下新的代码</span><!----></div><div data-v-6fd44370="" class="footer"><span data-v-6fd44370="" class="date">1月前</span><a data-v-6fd44370="" class="reply-btn">回复</a><!----></div></div><!----></div></li></ul><!----></div><form data-v-4afc11f9="" class="reply-form"><textarea data-v-4afc11f9="" rows="1" maxlength="1024" placeholder="评论审核通过后显示" style="overflow: hidden; overflow-wrap: break-word; height: 35px;"></textarea><button data-v-4afc11f9="" class="reply-btn">评论</button></form></div></div></div><!----></div></li><li data-v-6adae277="" class="item"><div data-v-38783431="" data-v-6adae277="" class="comment"><div data-v-3a6943ce="" data-v-38783431="" st:block="userPopover" st:state="5bee78d0e51d452ade4fb053" class="user-popover-box"><!----><a data-v-38783431="" href="https://juejin.im/user/5bee78d0e51d452ade4fb053" target="_blank" rel="" data-v-3a6943ce=""><div data-v-57c47624="" data-v-cf310dfc="" data-v-38783431="" data-src="https://avatars2.githubusercontent.com/u/33317030?v=4" class="lazy avatar avatar" style="background-image: none;"></div></a></div><div data-v-38783431="" class="content-box"><div data-v-38783431="" class="header"><div data-v-38783431="" class="user-info"><div data-v-3a6943ce="" data-v-38783431="" st:block="userPopover" st:state="5bee78d0e51d452ade4fb053" class="user-popover-box"><!----><a data-v-38783431="" href="https://juejin.im/user/5bee78d0e51d452ade4fb053" target="_blank" rel="" class="username" data-v-3a6943ce="">zhaofeihao</a></div><div data-v-38783431="" class="position">前端 @ caiji</div></div></div><div data-v-38783431="" class="content"><!----><span data-v-38783431="" class="content-html">for(var i = 0; i &lt; 6; i++){
	setTimeout(function timer(){
		console.log(i)
	}, i*1000)
}
对于上面的i*1000中的i来说，i是6的话应该是6秒后执行，实际上并不是，没有理解原因，求指教~</span><!----></div><div data-v-38783431="" class="footer"><button data-v-38783431="" class="like-btn"><i data-v-38783431="" class="collection-arrow-ion ion-arrow-up-b"></i><span data-v-38783431="">0</span></button><span data-v-38783431="" class="sub-comment-btn text-pointer"><span data-v-38783431="" class="title">收起评论</span><div data-v-38783431="" class="sub-comment--arrow" style=""></div></span><span data-v-38783431="" class="date">1月前</span><!----></div><div data-v-4afc11f9="" data-v-38783431="" class="sub-comment-box sub-comment-box"><div data-v-4afc11f9="" class="sub-comment-box__top"><div data-v-4afc11f9="" class="icon-close"></div><h3 data-v-4afc11f9="">评论</h3></div><div data-v-4afc11f9="" class="sub-comment-box__inner"><div data-v-4afc11f9=""><ul data-v-4afc11f9="" class="sub-comment-list"><li data-v-4afc11f9="" class="item"><div data-v-6fd44370="" data-v-4afc11f9="" class="sub-comment sub-comment"><div data-v-3a6943ce="" data-v-6fd44370="" st:block="userPopover" st:state="574f8d8d2e958a005fd4edac" class="user-popover-box user-popover--avatar"><!----><div data-v-57c47624="" data-v-cf310dfc="" data-v-6fd44370="" data-src="https://user-gold-cdn.xitu.io/2018/10/30/166c3fd3666b5d05?imageView2/1/w/100/h/100/q/85/format/webp/interlace/1" class="lazy avatar avatar loaded" data-v-3a6943ce="" style="background-image: url(&quot;https://user-gold-cdn.xitu.io/2018/10/30/166c3fd3666b5d05?imageView2/1/w/100/h/100/q/85/format/webp/interlace/1&quot;);"></div></div><div data-v-6fd44370="" class="content-box"><div data-v-6fd44370="" class="header"><div data-v-6fd44370="" class="user-info"><div data-v-3a6943ce="" data-v-6fd44370="" st:block="userPopover" st:state="574f8d8d2e958a005fd4edac" class="user-popover-box user-popover--info"><!----><a data-v-6fd44370="" href="https://juejin.im/user/574f8d8d2e958a005fd4edac" target="_blank" rel="" class="username" data-v-3a6943ce="">yck</a></div><div data-v-6fd44370="" class="position"></div></div></div><div data-v-6fd44370="" class="content"><!----><span data-v-6fd44370="" class="content-html">i 每次递增，每次循环就增加一个定时器。setTimeout 是异步函数，需要等待循环结束才会执行内部回调，当内部回调执行的时候，i 已经是 6 了。</span><!----></div><div data-v-6fd44370="" class="footer"><span data-v-6fd44370="" class="date">1月前</span><a data-v-6fd44370="" class="reply-btn">回复</a><!----></div></div><!----></div></li><li data-v-4afc11f9="" class="item"><div data-v-6fd44370="" data-v-4afc11f9="" class="sub-comment sub-comment"><div data-v-3a6943ce="" data-v-6fd44370="" st:block="userPopover" st:state="5bee78d0e51d452ade4fb053" class="user-popover-box user-popover--avatar"><!----><div data-v-57c47624="" data-v-cf310dfc="" data-v-6fd44370="" data-src="https://avatars2.githubusercontent.com/u/33317030?v=4" class="lazy avatar avatar" data-v-3a6943ce="" style="background-image: none;"></div></div><div data-v-6fd44370="" class="content-box"><div data-v-6fd44370="" class="header"><div data-v-6fd44370="" class="user-info"><div data-v-3a6943ce="" data-v-6fd44370="" st:block="userPopover" st:state="5bee78d0e51d452ade4fb053" class="user-popover-box user-popover--info"><!----><a data-v-6fd44370="" href="https://juejin.im/user/5bee78d0e51d452ade4fb053" target="_blank" rel="" class="username" data-v-3a6943ce="">zhaofeihao</a></div><div data-v-6fd44370="" class="position">前端 @ caiji</div></div></div><div data-v-6fd44370="" class="content"><span data-v-6fd44370="" class="text-reply">回复<a data-v-6fd44370="" href="https://juejin.im/user/574f8d8d2e958a005fd4edac" target="_blank" rel=""><span data-v-6fd44370="" class="username">yck</span></a>：</span><span data-v-6fd44370="" class="content-html">懂了懂了，灰常感谢</span><!----></div><div data-v-6fd44370="" class="footer"><span data-v-6fd44370="" class="date">1月前</span><a data-v-6fd44370="" class="reply-btn">回复</a><!----></div></div><!----></div></li></ul><!----></div><form data-v-4afc11f9="" class="reply-form"><textarea data-v-4afc11f9="" rows="1" maxlength="1024" placeholder="评论审核通过后显示" style="overflow: hidden; overflow-wrap: break-word; height: 35px;"></textarea><button data-v-4afc11f9="" class="reply-btn">评论</button></form></div></div></div><!----></div></li><li data-v-6adae277="" class="item"><div data-v-38783431="" data-v-6adae277="" class="comment"><div data-v-3a6943ce="" data-v-38783431="" st:block="userPopover" st:state="5b8df5cf51882543057da9f6" class="user-popover-box"><!----><a data-v-38783431="" href="https://juejin.im/user/5b8df5cf51882543057da9f6" target="_blank" rel="" data-v-3a6943ce=""><div data-v-57c47624="" data-v-cf310dfc="" data-v-38783431="" data-src="https://user-gold-cdn.xitu.io/2018/9/18/165ea3d42c4e681d?imageView2/1/w/100/h/100/q/85/format/webp/interlace/1" class="lazy avatar avatar" style="background-image: none;"></div></a></div><div data-v-38783431="" class="content-box"><div data-v-38783431="" class="header"><div data-v-38783431="" class="user-info"><div data-v-3a6943ce="" data-v-38783431="" st:block="userPopover" st:state="5b8df5cf51882543057da9f6" class="user-popover-box"><!----><a data-v-38783431="" href="https://juejin.im/user/5b8df5cf51882543057da9f6" target="_blank" rel="" class="username" data-v-3a6943ce="">liuxngxing</a></div><div data-v-38783431="" class="position"></div></div></div><div data-v-38783431="" class="content"><!----><span data-v-38783431="" class="content-html">面试命中率最高的闭包、深浅拷贝、原型，都有了！关键写的还那么通俗易懂！作者是大佬！羡慕……</span><!----></div><div data-v-38783431="" class="footer"><button data-v-38783431="" class="like-btn"><i data-v-38783431="" class="collection-arrow-ion ion-arrow-up-b"></i><span data-v-38783431="">1</span></button><span data-v-38783431="" class="sub-comment-btn text-pointer"><span data-v-38783431="" class="title">评论</span><div data-v-38783431="" class="sub-comment--arrow" style="display: none;"></div></span><span data-v-38783431="" class="date">1月前</span><!----></div><!----></div><!----></div></li><li data-v-6adae277="" class="item"><div data-v-38783431="" data-v-6adae277="" class="comment"><div data-v-3a6943ce="" data-v-38783431="" st:block="userPopover" st:state="5a33848a6fb9a0450a676740" class="user-popover-box"><!----><a data-v-38783431="" href="https://juejin.im/user/5a33848a6fb9a0450a676740" target="_blank" rel="" data-v-3a6943ce=""><div data-v-57c47624="" data-v-cf310dfc="" data-v-38783431="" data-src="https://user-gold-cdn.xitu.io/2018/10/12/166668883006ee0b?imageView2/1/w/100/h/100/q/85/format/webp/interlace/1" class="lazy avatar avatar" style="background-image: none;"></div></a></div><div data-v-38783431="" class="content-box"><div data-v-38783431="" class="header"><div data-v-38783431="" class="user-info"><div data-v-3a6943ce="" data-v-38783431="" st:block="userPopover" st:state="5a33848a6fb9a0450a676740" class="user-popover-box"><!----><a data-v-38783431="" href="https://juejin.im/user/5a33848a6fb9a0450a676740" target="_blank" rel="" class="username" data-v-3a6943ce="">前端指南小组</a></div><div data-v-38783431="" class="position">前端 @ FEGuide</div></div></div><div data-v-38783431="" class="content"><!----><span data-v-38783431="" class="content-html">啊，写的真好</span><!----></div><div data-v-38783431="" class="footer"><button data-v-38783431="" class="like-btn"><i data-v-38783431="" class="collection-arrow-ion ion-arrow-up-b"></i><span data-v-38783431="">2</span></button><span data-v-38783431="" class="sub-comment-btn text-pointer"><span data-v-38783431="" class="title">评论</span><div data-v-38783431="" class="sub-comment--arrow" style="display: none;"></div></span><span data-v-38783431="" class="date">1月前</span><!----></div><!----></div><!----></div></li><!----></ul></section></div></div><!----><!----></div></div><div data-v-06852630="" data-v-25b273c2="" class="book-handle book-direction" style=""><div data-v-06852630="" class="step-btn step-btn--prev"><img data-v-06852630="" src="./3.JS 基础知识点及常考面试题（二）_files/prev.87ad47e.svg"></div><div data-v-06852630="" class="step-btn step-btn--next"><img data-v-06852630="" src="./3.JS 基础知识点及常考面试题（二）_files/next.54d8a35.svg"></div><!----><!----></div><!----></div></div></section><!----><!----><!----><div data-v-2a6f6ec0="" data-v-25b273c2="" class="image-viewer-box"><!----></div></div><!----></div>
      
      
      <script type="text/javascript" src="./3.JS 基础知识点及常考面试题（二）_files/runtime.24cd77f11899da1ef6dd.js"></script><script type="text/javascript" src="./3.JS 基础知识点及常考面试题（二）_files/0.2c5447c62a349d40ad0f.js"></script><script type="text/javascript" src="./3.JS 基础知识点及常考面试题（二）_files/1.8a1ec2e286c0cc0327eb.js"></script>
    </body></html>